0

Passing null for a parameter of record type to custom functions

Hello Friends,

I did a lot of finding on this and finally resolved it by chance (couldn't find anything in the forum or on internet) that in order to pass a null parameter (that is expected to be of type record), we cannot simply pass "null". We have to actually create a temporary variable with value "this", then make it null and then pass it to the function.

"-- create a temporary reference to a record";
let nullRec := this;

"-- make the reference null";
nullRec = null;

"-- pass null parameter to the function";
let pmtData := parseJSON(validateBillPayments(nullRec));

text(pmtData.message)

if I write the above function call as:

let pmtData := parseJSON(validatePayments(null));

OR

let pmtData := parseJSON(validatePayments(record(null)));

OR

let pmtData := parseJSON(validatePayments(number(null)));

I get an error "Expected node in the function call, passed void"

 

Is there a better way/syntax/code to achieve the above solution?? If no, then don't understand why is Ninox scripting so weird and there is such depth of documentation !!

 

Thanks,

Vermaji

-------------------------------

1 reply

null
    • Elena_Rodriguez
    • 2 wk ago
    • Reported - view

    Hello Vermaji,
    I haven't tried the rest of your code, but I think that you missed a ":" in your code in this line:
     "-- make the reference null"; nullRec := null;
    Have a nice day!

Content aside

  • 2 wk agoLast active
  • 1Replies
  • 21Views
  • 2 Following