I created a Time field (not datetime) and I want to set its value with a script.
I have tried the following:
inRecord.setFieldValue(broadcast_jst_id, "01:05");
inRecord.setFieldValue(broadcast_jst_id, new Date("01:05"));
Unfortunately after the script runs the field is blank.
Did you call form.saveAllChanges()
after you called record.setFieldValue()
?
It does require a proper Date object, so the first example wouldn’t work.
Also, new Date("01:05")
is an invalid date.
See this page for Date examples:
https://www.w3schools.com/js/js_dates.asp
Hi Brendan. Yes, I’m calling saveAllChanges()
. All other fields get populated correctly, it’s just this one that doesn’t.
I tried doing it like this:
inRecord.setFieldValue(broadcast_jst_id, new Date(0,0,0,1,5,0));
But Tapforms displays “00:32” for some weird reason. Note that this this just a time field (Not Datetime).
I think I will have to specify dummy year, month, and days in order to make it work. Gonna test that now.
EDIT: Specifying dummy year, month, day worked like a charm.
inRecord.setFieldValue(broadcast_jst_id, new Date(2017,1,1,1,5,0));
You should set the dummy date to be January 1, 1970. That’s the Unix Epoch date/time which is what Tap Forms uses when it populates a Time field.
That’s a good idea. I’m gonna make that the dummy values. Thanks.