Date xxx days from now
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2013 05:53 AM
Anyone have any thoughts or examples of how to get ServiceNow to take any of the gs.(date records) like Now() and add say 2 days to it? What I'm attempting to to do is make it so that the default date that is presented on a request form shows a date that is at least 2 days in the future? Many of the other tools I support and work with I would just do something simple like Now()+2, however from a ServiceNow perspective all that yeilds is the value for today?
I've looked at http://wiki.servicenow.com/?title=GlideSystem and it has several examples of how to script time / hours in the past however it looks like they never thought to add anything that would be useful for days from now?
Likewise I already use scripts that can validate end time is greater than start time, however those really don't help me when it comes to setting a default value for a future date.
Thank in Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2013 06:18 AM
Hello,
Did you try to use a negative value (for example "gs.daysAgoStart('-5')")?
I made a test and it works!
Regards,
Anamaria
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2013 06:03 AM
I think there is a slight syntax error in Anamaria's script, no quotes around the number.
gs.daysAgoStart(-5)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-22-2013 06:57 AM
I had forgotten the negative value piece of ServiceNow, however my current instance doesn't like that script expression so I'm going to try another on a different build and see if it's a build issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2013 03:39 AM
Did you have to change the field type from date/time to string or something else in order to get this to work? When I try the gs.daysAgoStart('-5') or variations of it I can't get any of my versions or instance builds to want to display anything? I tried on a couple Calgary instances, and a Dublin, all had the same result. I also tried adding it as a Javascript:gs.dayAgoStart(-5) with the same results?