How can I prevent a Netsuite custom field formula from displaying an error caused by a (temporarily) missing field? - formula

I want to display the quantity remaining (qty ordered less qty fulfilled) on the lines of a sales order. I'm using the suggestion here:
http://www.netsuiterp.com/2018/09/add-quantity-remaining-column-on-sales.html
with a small tweak of the formula to exclude closed lines (case when {isclosed} <> 'T' then {quantity}-{quantityfulfilled} else 0 end).
The problem I'm having is that though it works perfectly for sales orders once they've been saved, when a user is creating a new sales order this field displays an error apparently because one of the fields referenced in my formula doesn't exist yet for that transaction. Usually it is "ERROR: Field 'quantityfulfilled' Not Found". I've tried adding some null-value handling to my formula, like adding
and nvl({quantityfulfilled},'') <> ''
to the 'when' condition, but I'm guessing the absence of the field is different from a null value since the error is unaffected. This is distracting and confusing to users. Is there a way to prevent it from displaying?

in scripts checking on internal id can be used as a test for a new record so:
case when {internalid} is null then 0 when {isclosed} = 'T' then 0 else {quantity}-{quantityfulfilled} end

Related

NetSuite System Notes CASE formula returning all notes

I've added a formula(date/time) column to a saved search in NetSuite, to return a system notes' date.
My CASE formula is returning all the system notes row's, and I would like a specific row's date i.e. 'POP Host Int ID' date.
How can I specify the row to return the date from, or remove the rows with no date that are not relevant?
CASE
WHEN {systemnotes.field} = 'POP Host Int ID' AND {systemnotes.type} = 'Set'
THEN {systemnotes.date}
ELSE NULL
END
It appears that my WHEN logic works to identify the record's system notes do contain an entry for 'POP Host Int ID' but in THEN I'm not specifying which row to get the date from so it returns all rows. And I could be wrong on this part.
Example results
Example System Notes for 1 record
Thank you for your assistance.
The CASE statement doesn't determine which rows are returned, only what data is returned for that field. On the other hand, the reference to the systemnotes table creates a join that causes each record result to be repeated for every system note entry.
To avoid this, add {systemnotes.field} = 'POP Host Int ID' and {systemnotes.type} = 'Set' as Filters in the Criteria tab instead of in the WHEN conditions. You can then just add the field under results instead of needing a formula.
Edit in response to comment below:
In cases where you need one result per base record (user), but they don't all have valid values from the joined table (system notes), I'd suggest grouping the results by user, and using aggregation functions for all the columns. EG: For the column in question I'm assuming you are getting one valid result and a lot of blanks per user. If you group by user and set the Summarize function to MAX, you should just get one result where the valid value is returned. If no valid value exists from the system notes, you would still get a result from the user and that field will be blank.
If you are creating a saved search the place to do this is in the criteria section.
The views you've shared are for the System Notes pertaining to a single record.
For those views you could just use the Field selector in the Filters section to select your POP Host Ing ID field.
For a saved search you would use the Advanced view and scroll down the criteria field list. Near the bottom are the System Notes. You can filter on Field, Date etc

How to validate against item master table

I am creating a custom report screen in which I have a fields item number, item type, prod line and status and there is a condition for item number that is I have to validate it against pt_mstr which from what i understand means that the item number that I enter should be present in pt_mstr. And if it's blank then give an error. I've done the validation for blank with this code
If lvc_part = "" then do:
{us/bbi/pxmsg.i &msgnum=40 &errorlevel=3}
Undo mainloop, retry mainloop.
End.
Lvc_part is the variable i declared for item number and mainloop is the loop inside which I'm writing my entire logic. I am getting the general idea for validating item number against pt_mstr but I'm not getting how to put it down as a code. I'm thinking we need to include a find first query to see if the item number is present in pt_mstr or not but I'm not sure. Any leads would be helpful, if you want to know anything regarding the declarations I've used or anything else let me know. Thanks in advance!
You need to add code like this
IF NOT CAN-FIND (FIRST pt_mstr WHERE pt_mstr.<keyfieldname> = lvc_part) THEN
<display error message>
or when it's a index with multiple fields:
IF NOT CAN-FIND (FIRST pt_mstr WHERE pt_mstr.<keyfieldname1> = lvc_part
AND pt_mstr.<keyfieldname2> = <value>) THEN
<display error message>
Most likely you can (and should) leave out the FIRST phrase in the CAN-FIND expression as typically you'd be using a UNIQUE find here.

Variable length column overflow whe using TFDLocalSQL

I try to query a clientdataset (cdsSource) with TFDLocalSQL.
The clientdataset has persistent fields, some are stringfields, size 1.
I do a select * from cdsSource , and get an error : "Variable length column overflow".
I found the cause and the solution, but think this is not the way it should be:
The error occurs when the order of the field in the query is different from the order of the persistent fields.
I think the following picture is self-explaining.
It is clear that the data of column "volgnummer" is assigned to the field "NietOpLaadLijst"
the question is : Is this by design ? Or is it a bug ?
Whatever it is, it is extremly confusing .
kind regards,
Dirk Janssens.

How to conditionally show fields based on value

I'm trying to use a calculation field to conditionally display one of two other fields based on whether or not each one has a value. Only one of the fields I'm looking at can actually have a value. So if field one has value, write field one. If field two has a value write field two. If neither fields have a value, write nothing.
My calculated statement is written as follows.
Case (
FieldOne != ""; FieldOne;
FieldTwo != ""; FieldTwo;
"")
In instances where neither field one or two have a value, nothing is written which is the expected behavior. However, if either field one or two have a value(a DATE) I'm getting some numeric value displayed. Any thoughts on what I'm doing wrong?
If you're positive that only one field can have a value, then you don't need the Case statement, btw.
FieldOne & FieldTwo

AX 2009: Report Range on enums parsing enum value commas?

I think I may have found an interesting bug with AX 2009, and I'm unsure of how I can proceed.
I am attempting to write a new report, and one of the conditions of this report is to be filtered based on the Posting field of the LedgerTrans table. However, it seems that when the report goes to execute, the label of the enum Purchase, receipt is parsed without regard to the quotes. This normally wouldn't be a problem, but the enum label in this case contains a comma. The result is that when run the query dialog box reads: Purchase, consumption, __ILLEGAL_VALUE__. I get this result even if I use the enum value or name. The report must be left interactive, but this field must be locked, so we cannot get the users to adjust the query at run time.
At this point I don't want to change the label itself, but if it is the only way to solve this I will. Has anyone else run into this, or know how we could overcome it?
I've run into this before. Sometimes an acceptable option is hard-coding the conditional values as an OR statement, rather than the comma separated list:
((LedgerTrans.Posting == LedgerPostingType::PurchReceipt) || (LedgerTrans.Posting == LedgerPostingType::PurchConsump))
That can be typed into a range filter box, or can be set as the value of a range via x++ code:
ledgerPostingRange.value("((LedgerTrans.Posting == LedgerPostingType::PurchReceipt) ||
(LedgerTrans.Posting == LedgerPostingType::PurchConsump))");
AX doesn't try to convert these to the labels, so they stay as distinct values, instead of being rendered as labels. Note that parentheses are required for it to be parsed properly.
Since the ILLEGAL_VALUE can appear even when attempting to use a single value that contains a comma in its label, the same can be done for a single :
ledgerPostingRange.value("(LedgerTrans.Posting == LedgerPostingType::PurchReceipt)");
I would definitely change the label! But as a workaround you could use the enum value's number instead.
If the field is often queried, you could put the field in a dialog then change the query:
ledgerPostingRange.value(ledgerPostingType ? int2str(ledgerPostingType) : '');

Resources