Copy link to clipboard
Copied
hi
I created this code to copy the date entered in the "PURCHASE DATE" field with mm/yy format.
I inserted the formula in the calculation script of the "DATA_2" field
var s1 = this.getField("PURCHASE DATE").value;
if (s1 !== "") {var a1 = s1.replace(/\//g, '');
var b1 = util.scand("mmyy", a1);
event.value = util.printd("mm yy", b1);}
else {event.value = "";}
the console message is:
TypeError: Invalid argument type.
Util.printd:4:Console undefined:Exec
===> oDate parameter.
Please, can anyone help me find the solution?
Copy link to clipboard
Copied
I'd have to see the test values, but util.scand() is probably returning null because the input is either ambigous or doesn't match. Why did you remove the "/"? the slash removes ambigouity.
Copy link to clipboard
Copied
I found the error
the "PURCHASE DATE" field was ddmmyyyy and not mmyy
Thank you very much
Copy link to clipboard
Copied
So the input didn't match the specified format. Definately an issue, and something that could be checked with a regular expression before proceeding with the script.
However, it is also a problem to not have separators in the date string. The separators make recognition of the date elements explicit.