Calculating a default value for a date variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-08-2012 02:02 PM
I have a date variable field labeled 'start date' and I have another date field labeled 'expiration date'. What I am trying to do in a client script is default the expiration date 90 days from the start date. Also prevent end users from changing the expiration date beyond the 90 days. However they can change it to an earlier time. So (1) first thing is how to default the expiration date to 90 days from the start date and (2) prevent users from changing the expiration beyond the 90 days allowed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-02-2013 08:39 PM
Did you figure this out? I'm pretty new to this and trying to put a requested by date a few days out. I tried putting this in as the default value for the date/time variable, but it doesn't work.
gs.now().getNumericValue() + 86400000
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2013 01:33 AM
Did you try that :
javascript:gs.nowDateTime()+ 86400000;
(default value field can also contain a hard-coded value, like a static string or somethign like that; If you need to call a method, you have to indicate the javascript prefix)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2013 04:29 PM
set the default value on the variable to javascript:gs.daysAgo(-5) this will set the date 5 days in the future.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2013 12:38 PM
Both of these options seem to give completely random results. Every time you load the form, the default date is something completely different...sometimes a few hours in advance...sometimes months.
This script seems to work...from michael.baker in Default value + 2 weeks for date variable:
[quote]Your results are due to your user date format set differently than the system date format. Try the below code in the default value instead.
[/quote]
javascript:var d = new GlideDateTime(); d.setValue(gs.daysAgo(-14)); d.getDisplayValue();