I have a form in Tap Forms Pro that calculates subscription renewal dates to keep track of all my subscriptions. It uses several calculation fields that use Date and Time functions to determine the renewal date. I would like to create a script to consolidate all the calculations into one script field.
Using a post here from May 2, 2020, “how to use dateadd in a script”, I tried this as a test, but got an error that said Test: ReferenceError: Can’t find variable: dateadd, line:(null).
function Test() {
var start_date = record.getFieldValue('fld-037157d2f1fa4a75959f3a6c0128a8c1');
var renew_date = dateadd(start_date,1,0,0,0,0,0,0);
return renew_date;
}
Test();
Is it possible to use the these functions from calculation fields such as TODAY, NOW, DATEADD, YEARS, MONTHS, and DAYS in a script?
Thanks,
Harry
You have to use the Javascript equivalent. There’s a bunch of functions available: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date.
dateadd()
is not a Javascript function and can’t be used. If you continue to go through the thread you found, you’ll see how to add an hour to your current date/time. Here’s the link to the thread for everyone else following: https://www.tapforms.com/forums/topic/how-to-use-dateadd-in-a-script/#post-40449
Thanks so much. Exactly what I was looking for. Now to translate all my algorithms using JavaScript functions.