NetSuite Saved Search where {location} = {user.location}? - mysql

This seems like it should be simple, but for some reason I can't get this to work... I am trying to build a transaction saved search that shows the user (person viewing the search) all transfer orders that have their location in either the {location} field or {transferlocation} field. Here is the formula (Numeric) I am adding to the criteria and setting is equal to 1:
CASE WHEN {location} = {user.location} THEN 1 ELSE 0 END
Seems pretty simple, but this formula errors out. I have also tried this and it doesn't error, but I get 0 results:
CASE WHEN {location} LIKE {user.location} THEN 1 ELSE 0 END
Once I get this to succeed I should be able to either add to this formula or add a new formula criteria for the {transferlocation}. Either way, any suggestions would be great. Below I will add all criteria/results/filters just for transparency:
Criteria:
Main Line is True
Type is Transfer Order
Status is any of Transfer Order:Partially Fulfilled, Transfer Order:Pending Approval, Transfer Order:Pending Fulfillment, Transfer Order:Pending Receipt, Transfer Order:Pending Receipt/Partially Fulfilled
(not working) Formula (Numeric) is 1 CASE WHEN {user.location} = {location} OR {user.location} = {transferlocation} THEN 1 ELSE 0 END
Results:
Date Created
Document Number
Location
To Location
Filters:
Date Created

In a lot of case, when you use Numeric Formula, it seems like NS prefer using internalIds, so use this in your formula and it should work (tested):
CASE WHEN {location.id} = {user.location.id} THEN 1 ELSE 0 END

Most likely due to NetSuite perceiving the possibility of data type differences. Try wrapping your location fields in NVL and/or TO_CHAR or using ...location.id}

Related

XPages JSON service not returning all records when using search

I am display data in a fullcalendar via a JSON service (calling a Lotus Notes database). If I do a simple call, all the data is returned - which is good but there are over 3000 documents, so this slows the calendar response. When I try and reduce the number of records being returned via a search such as
" FIELD EV_StartTime >= 01-10-2018 AND FIELD EV_EndTime <= 01-06-2019";
or
" FIELD EV_Category = Watches "
then only 33 records are returned (1095 expected)
I have the count field set to 1000 as suggested by others but this has made no difference (tho it does when I have no search criteria).
Thanks for any suggestions!
In case anyone else has a this issue, in the Rest Service control there is a property called searchMaxDocs which requires a value, when doing a search, otherwise it appears to default to a smallish value

Allow or disallow value change in combo box based on initial value to new value

I am trying to write code for a data certification status combobox that will allow or not allow the user to change the status based on specific guidelines:
User may change status from Raw to Clean, no restriction
User may change status from Clean to Certified, no restriction
User may change status from Raw to Certified after answering yes to verify all necessary QA/QC has been done
User may change status from Clean to Raw, if answers yes to proceed and provides explanation in "Comments" field
User may not change status from Certified to Clean, or from Certified to Raw
I assume I would use a Select statement where Case 1 = Raw (ID=1), Case 2 = Clean (ID=2), Case 3 = Certified (ID=3). The IDs 1, 2, and 3 are the ID values in the lookup table for the data certification status'. What I'm struggling with is how I set the "Before" value to compare to the "Current" value, when the user has already selected a different value.
Also, I'm using the "OnChange" event. But wondering if "BeforeUpdate" or "OnDirty" events would be better.
Any help would be greatly appreciated.
use "BeforeUpdate" Event on combox
If Me.Combo3.OldValue = 1 And Me.Combo3.Value = 2 Then
Dim x
x = MsgBox("all necessary QA/QC has been done? ", vbYesNo)
If x = vbNo Then
MsgBox "any thing you want to write"
Cancel = True
End If
End If

Return single value based on conditional CASE

I have no background with MySQL and have not been able to find the appropriate stepping stones to accomplish writing this particular query.
Objective:
I have created a report that shows the approval status of artwork per page. Artists have to access the proof however to determine if there is any markup/notes on each page. I want to add single column to the report that will have one of three string values per page for each proof. The string will either be "Yes", No", or "Missed" based on certain conditions.
Each proof can have multiple pages. Each page can have multiple marks (think of drawing a circle around something). Each mark can have multiple notes. This is where, for me, things get hazy. I am aware of the need to avoid RBAR queries, but I am unsure how to query against multiple comments and then marks by page.
Conditions:
This is the RBAR query I have for handling the notes/comments. This is fine for dealing with each comment, but obviously on a report there is no reason to see each comment row.
SELECT *,
CASE WHEN note IS NULL OR ' ' AND deleted = FALSE
THEN 'Missed' ELSE 'Yes'
END AS 'Comment'
FROM rvm_comment
Knowing that a mark can have multiple comments, I need to determine if any rows in rvm_comment.note are NOT NULL or contain just a space, ' '. If so, the mark is represented as "Yes". Otherwise the mark would be "Missed".
This should then be condensed/nested in a manner that each mark is compared.
If any mark on a page is "Yes" then output in that row would be "Yes". Otherwise, "Missed".
If this doesn't make sense, hopefully the following information will shed some light.
Tables and Relationships:
DSE_OBJECT Table:
This table is associated with a request that a proof can be attached to. The ID is the PK.
RVM_REVIEW_OBJECT Table:
This table is essentially the proof instance itself. A proof can have any number of pages (min 1). ID is the PK, review_object is the FK.
RVM_MARK Table:
This table contains information on marks that are added to a proof, including the page they exist on. ID is the PK, review_object is the FK. (NOT LISTED) Deleted is used to prevent returning results where a mark is deleted by the user. rvm_mark.deleted = FALSE
RVM_COMMENT Table:
This table is where the notes (strings) are stored. Deleted is used to prevent returning results where a note is deleted by the user (rvm_comment.deleted = FALSE). There is a flaw in the system where a comment can be created but if the user doesn't hit "enter" on their keyboard after typing the text is not saved in to the DB. This is why we need to test for NULL in rvm_comment.note.
Raw Data for Testing and Summary: Dropbox with CSVs for the tables
As a courtesy I have included some raw data in CSV form for anyone will to try it out. (click Dropbox link above).
So, to summarize again. I am trying to write a query that will condense those tables to a single string (AS Comment),for each rvm_mark.page_no. The string is based on a) whether or not rvm_comment.note is NULL or ' ', and b) whether any rvm_mark.id that has matching rvm_mark.page_no, has rvm_comment.note that isn't NULL.
EDIT UPDATE 12/14/16:
Thanks to Barmar I was able to take a step towards the final result. I am currently stuck on trying to return the string 'No' for any situations where there are no comments. This should only be when rvm_review_object.id does not have a matching value in rvm_mark.review_object.
SELECT rvm_review_object.dse_object_id, rvm_review_object.id,
T_Mark.creator, T_Mark.review_object,
CASE WHEN T_Mark.review_object IS NULL THEN 'No'
ELSE T_Mark.Comment
END AS Comment
FROM rvm_review_object
LEFT JOIN(
SELECT rvm_mark.review_object, rvm_mark.creator, rvm_mark.id,
CASE WHEN MAX(T_Comment.Comment = 'Yes') = 1 THEN 'Yes'
ELSE 'Missed'
END AS Comment
FROM rvm_mark
LEFT JOIN(
SELECT rvm_comment.mark,
CASE WHEN MAX((rvm_comment.note IS NULL OR rvm_comment.note = '')
AND rvm_comment.deleted = FALSE) = 1
THEN 'Missed'
ELSE 'Yes'
END AS Comment
FROM rvm_comment
GROUP BY rvm_comment.mark) AS T_Comment
ON T_Comment.mark = rvm_mark.id
WHERE rvm_mark.deleted = FALSE
GROUP BY rvm_mark.review_object) AS T_Mark
ON T_Mark.review_object = rvm_review_object.id
WHERE rvm_review_object.creator != T_Mark.creator
You need to group the query by mark. You can then use MAX() to determine if any of the rows in the group match the condition.
SELECT mark,
CASE WHEN MAX((note IS NULL OR note = '') AND deleted = FALSE) = 1
THEN 'Missed'
ELSE 'Yes'
END AS Comment
FROM rvm_comment
GROUP BY mark

MySQL finding data if any 4 of 5 columns are found in a row

I have an imported table of several thousand customers, the development I am working on runs on the basis of anonymity for purchase checkouts (customers do not need to log in to check out), but if enough of their details match the database record then do a soft match and email the (probably new) email address and eventually associate the anonymous checkout with the account record on file.
This is rolling out this way due to the age of the records, many people have the same postal address or names but not the same email address, likewise some people will have moved house and some people will have changed name (marriage etc).
What I think I am looking for is a MySQL CASE system, however the CASE questions on Stack Overflow I've found don't appear to cover what I'm trying to get from this query.
The query should work something like this:
$input[0] = postcode (zip code)
$input[1] = postal address
$input[2] = phone number
$input[3] = surname
$input[4] = forename
SELECT account_id FROM account WHERE <4 or more of the variables listed match the same row>
The only way I KNOW I can do this is with a massive bunch of OR statements but that's excessive and I'm sure there's a cleaner more concise method.
I also apologise in advance if this is relatively easy but I don't [think I] know the keyword to research constructing this. As I say, CASE is my best guess.
I'm having trouble working out how to manipulate CASE to fit what I'm trying to do. I do not need to return the values only the account_id from the valid row (only) that matches 4 or 5 of the given inputs.
I imagine that I could construct a layout that does this:
SELECT account_id CASE <if postcode_column=postcode_var> X=X+1
CASE <if surname_column=surname_var> X=X+1
...
...
WHERE X > 3
Is CASE the right idea?
If not, What is the process I need to use to achieve the desired results?
What is [another] MySQL keyword / syntax I need to research, if not CASE.
Here is your pseudo query:
SELECT account_id
FROM account
WHERE (postcode = 'pc')+
(postal_address = 'pa')+
(phone_number = '12345678901')+
(surname = 'sn')+
(forename= 'fn') > 3

Access writng to wrong row number

4150
NRrows = RSNonResourceCosts.RecordCount ' Number of Rows in Non Resource Table
NRCols = RSNonResourceCosts.Fields.Count ' Number of Fields in NonResource Table
Dim CL(1 To 10) As Integer ' This is to count "filled rows" when spreadsheet is filled
Dim Header(1 To 10) As String
'-----------
'Find the Headers (Taken from Actual Table and not predefined as original)
For Each Recordsetfieldx In RSNonResourceCosts.Fields
If C > 0 Then
Header(C) = Recordsetfieldx.Name
End If
C = C + 1
Next Recordsetfieldx
4170
R = 0
'Write to worksheet
RSNonResourceCosts.MoveFirst
Do Until RSNonResourceCosts.EOF
For C = 1 To NRCols - 1
FieldName = RSNonResourceCosts.Fields(C).Value
If RSNonResourceCosts.Fields(Header(C)).Value <> "" Then
CL(C) = CL(C) + 1
WKS.Cells(200 + R, C) = RSNonResourceCosts.Fields(Header(C)).Value
End If
Next C
RSNonResourceCosts.MoveNext
R = R + 1
Loop
I attach code. Have solved part of original by defining Recordset. User can add column to Table. First part of code determines the headers. Second part determines values and writes to worksheet. The new Rows are appearing first on the worksheet and in wrong column. I tried attaching worksheet but it looked awful. Any help would be appreciated.
Two things:
1) The order your records is the order they are in the recordset. If you want them in a particular order, try sorting them (perhaps with an ORDER BY in the underlying SQL statement)
2) For the column issue: In the first bit of code, I don't see where C is initialized, but keep in mind the Headers and Fields both start with an index of 0, so if you set Header(1) = the first field's header (index 0), but then copy the data in the fields without shifting the index value, it will shift everything over by one column.
As an added note, you might want to consider what happens when you have more than 10 columns. Using fixed-length arrays means your code will break. You might want to read about using a dynamic array and ReDim.
I don't yet feel like I have completely grasped the entirety of the problem yet, but let me take a stab at it. From what I do understand, data is being written from your record set into excel (good), but it is going into the 'wrong row' (question title) and the 'wrong column' (question text).
From what I see, I don't know the purpose of FieldName = RSNonResourceCosts.Fields(C).Value, but I want to make sure that you understand that RSNonResourceCosts.Fields(C).Value is not necessarily equivalent to RSNonResourceCosts.Fields(Header(C)).Value. More than that, you are likely missing at least one column altogether in your output, or at least skipping over it accidentally. rs.Fields(0).name is the first 'column' in a recordset, but it is completely ignored in your code. Perhaps this is intentional, maybe it is a key field or something useless to you, but it is important that you are making that distinction intentionally. But, since I don't see where your code populates the headers in your worksheet, I wonder if 'wrong column' means every record has been shifted a column and your last column is sitting empty. That, coupled with the dubious omission of C being initialized as 0 (not 1, or anything else) in your above code, makes me concerned that Header(3) could possibly by field(1), or field(4), or I don't know. That would certainly also confuse the columns in your output, or at least make dependence on FieldName frustrating.
Another thing, really a shot in the dark: NRrows. I have had issues before, depending on how I create my recordset, of not getting the correct record count the first time. And, if I base the population of a worksheet, array, etc., on the number of rows and the records relative position in that number, my records get all sorts of wacky. Maybe you did this already, but since it isn't shown, I recommend a RSNonResourceCosts.movelast: RSNonResourceCosts.movefirst line before you define NRrows, just to be sure.
And last, if I am way off base here... then you really are going to have to show us the spreadsheet, even if it isn't your most beautiful work. We all know that if it were, you wouldn't be asking about it here... so set your pride aside, and be more specific as well as show us what the output looks like and how it should look.