Hi Brendan,
I’ve noticed a couple of weird things while building my first Form script. Not sure if I’m just being a noob (probably am).
Does alertWithMessage stop execution? Is this intended behaviour? If so, is there an alternative that won’t halt execution on iOS? Example:
Utils.alertWithMessage('test', 'this message will display');
Utils.alertWithMessage('test', 'this message will NEVER display');
Also:
Utils.alertWithMessage('test', '0 time: ' + new Date(0));
Displays:
test
0 time: Thu Jan 1 1970 00:00:00 GMT+0000 (GMT)
However, if I assign that value to a blank date field, formatted to display as HH:mm, with Set Current Time as OFF, using the code:
record.setFieldValue(test_time_id, new Date(0));
I get a value of 01:00, when I would expect a value of 00:00.
If I adjust for it, with the code:
record.setFieldValue(test_time_id, 0 - 60*60*1000);
… then I get the value of 00:00.
(I seem to remember an old TF bug similar to this many, many moons ago — I wonder if it has come back to haunt :) ).
Thanks for your help, as always.
Merry Christmas!
Hi David,
The alerts are shown asynchronously. If you want to continue code execution after you display an alert, use the Prompter() class instead. That has a callback method you can provide as a parameter that will let you continue execution after a button is clicked.
If you want the current date, just use new Date()
without passing in the 0
.
https://www.w3schools.com/jsref/jsref_obj_date.asp
But the value displayed in a Date field will depend on the time zone you’re located in. Are you 1 hour off of GMT?