- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2019 04:51 AM
I have a requirement that the user wants to set the value in a Date field to populate to today's date plus 5 days out. Any ideas on how to do this? It's just a date field I assume it's something in the default value that could achieve this I just ain't sure what??
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2019 05:09 AM
Hi Wendy
This should work for you: javascript: var gdt = new GlideDateTime(); gdt.addDays(5);gdt.getDate();
Hope it helps.
Matt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2019 05:04 AM
Hi,
go through below link it may help you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2019 05:09 AM
Hi Wendy
This should work for you: javascript: var gdt = new GlideDateTime(); gdt.addDays(5);gdt.getDate();
Hope it helps.
Matt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2019 05:16 AM
Thank you that was perfect - I just needed to add the AddDaysLocalTime() for some reason... Thanks so much
javascript: var gdt = new GlideDateTime(); gdt.addDaysLocalTime(5);gdt.getDate();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2019 05:15 AM
Hi there,
Have a look at the addDays part in this Docs page:
https://developer.servicenow.com/app.do#!/api_doc?v=london&id=r_GDT-addDays_N
Use it within the Variable Default Value with javascript: new GlideDatetime().addDays(5) etc..
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field