I have checked the previous posts regarding this and wanted to make sure if i was checking it corrected.
I am importing data through dataport in Stockkeeping Units table, and if the values are not specified in the spreadsheet, i want to assign default values from Item. For that i need to check if the data item has any value
For dateformula I am doing
IF FORMAT(“Stockkeeping Unit”.“Lead Time Calculation”) = ‘’ THEN
“Stockkeeping Unit”.“Lead Time Calculation” := Item.“Lead Time Calculation”;
For text
IF “Stockkeeping Unit”.“Vendor Item No.” =’’ THEN
“Stockkeeping Unit”.“Vendor Item No.” := Item.“Vendor Item No.”;
for integer/decimal
IF “Stockkeeping Unit”.“Unit Cost” =0 THEN
“Stockkeeping Unit”.“Unit Cost” := Item.“Unit Cost”;
How do i check it for OPTION. I am doing. But what if for zero there is an option string?
IF “Stockkeeping Unit”.“Reordering Policy” = 0 THEN
“Stockkeeping Unit”.“Reordering Policy” := Item.“Reordering Policy”;
Also how do I check for null value for Boolean type field?
Thanks
Never thought a boolean as not being either true or false…
Did you try the ISBOOLEAN function?
Use this function to find out whether a C/AL variant contains a boolean variable or not.
If the result is NOT OK then you will have to assign it a value.
Will the the function ISBOOlean return false if the field is null? how should i use it
// IF FORMAT(“Stockkeeping Unit”.Obsolete) = ‘’ THEN - earlier code
if use
IF “Stockkeeping Unit”.ISBOOLEAN(Obsolete) THEN I get an error
if ISBOOLEAN(“Stockkeeping Unit”.Obsolete) then - I et an error?
What is the equivalent of ISNULL function in NAvision as that is what i am trying to find out for boolean, option and all the other data types?
NAV doesn’t have null values.
The default initial value of a boolean type variable/field is FALSE.
Option type fields are stored as integer values, and the default initial value is 0, which represents the first option selection. Best practice C/AL code is to use the actual option value, not its integer value. The code will compile with the integer value but it is not very nice to read the code that way.
In your code example you’re talking about checking NAV table fields for NULL values. After the data is imported into NAV table fields none of the values will be NULL. As DenSter said, NULL values don’t exist in NAV.
You may run into import errors when the dataport tries to bring in a NULL or blank value from the file into an NAV table field. In this case use the OnBeforeEvaluateField trigger in the dataport. The value is text at that point and can be easily handled. If you change the value of the local var Text here it will change the value of what is actually put in the NAV table field specified by the import.
As for the option value of 0, that’s just a decision you’ll have to make. You’ll either code the dataport so that if the option field value imported results in the first option value (0), then assign it to the option value of the item or you’ll leave whatever is imported there. BTW, most of the time the blank value in an option field can be addressed like this: “Stockkeeping Unit”.“Reordering Policy”::" "
Thank you so much both of you.
OnBeforeEvaluateField trigger was what I needed. It is working perfectly. Again, appreciate your help.