Hi Brendan,
I try to assign the current date to a field using a script.
First try:
theRec.setFieldValue(date_sold_id, Date());
Doesn’t show anything. If I change date_sold to a text field it works. Then I tried to get the date number:
theRec.setFieldValue(date_sold_id, Date.parse(Date()));
Doesn’t work either. But something like this works:
theRec.setFieldValue(date_sold_id, theRec.getFieldValue(date_modified_id));
When using a script, how can I assign the current date to a field? Thanks!
— Daniel
Hi Daniel,
The problem with the Date() function is it’s returning the date as a String. And you’re trying to set that on a Date field.
So what you need to do is use:
var currentDate = new Date();
I just tested it and it works. Internally the new Date()
function will convert to an NSDate
which is what Tap Forms needs for setting on the field.
Thanks!
Brendan
Hi Brendan,
Perfect, this works for me too! Thank you for your help.
— Daniel