- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2015 03:01 PM
Hi,
I have a date field on a form. When a new form is opened, I want to add 14 days to the field. The new date (the day the form was opened +14) should not change, unless the user changes it manually - that is, I don't want the date to be calculated anew every time the form is loaded.
Also, if the date is changed by the user, an alert should pop up saying something like "you chose to change the date".
1. Where should the calculation of the field be? in a BR? Or the field's variable (Personalize Dictionary)?
2. I tried something like this in a BR:
var gdt = new GlideDateTime(current.u_nowdate); // If there's a better way to do it without this additional field u_nowdate, let me know (like gs.nowDateTime();)
gdt.addDays(14);
current.u_starting_date = gdt;
current.update();
It does not work, of-course
And then I thought about adding a client script (this works, but for it to be effective, i need the field date to be set correctly):
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
return confirm('You changed the starting date from ' + oldValue + ' to ' + newValue + " " +'\n' + 'Are you sure you want to do that?');
}
Solved! Go to Solution.
- Labels:
-
Integrations
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2015 03:13 PM
I would set this as the default value in the dictionary entry for the field. You would just need javascript:gs.daysAgo(-14); in that field. Then you could do your client script on change.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2015 03:13 PM
I would set this as the default value in the dictionary entry for the field. You would just need javascript:gs.daysAgo(-14); in that field. Then you could do your client script on change.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2015 03:18 PM
OK, I feel stupid now.
Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2015 03:24 PM
Ahh no way. Dates are so tricky to work with in SN that it's easy to assume it's going to be more complicated.