Set default date on date field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 12:55 AM
Hi,
I just created a new Date field that shows only when incident on hold. I am trying to set a default date using dictionaries default value, however none of the javascript GlideDateTime seem to work.
I just need to set the default value to be 6 days from current date. Please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 01:01 AM
You can use a 'before' business rule to set the default value of the date. The BR should run when the state changes to on hold, then you can use the GlideDateTime() api to set the desired date. (in this case it would be 6 days after the current date time).
Regards,
Aishwarya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 01:01 AM - edited 11-22-2022 01:03 AM
Hello @PrandeepSharma ,
Put this in the default value of the field dictionary
javascript: var gdt = new GlideDateTime();gdt.addDays(6);gdt.getDate();
Note (instead of &colon use colon symbol)
BR,
Nayan
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 01:15 AM
Hi I added javascript: var gdt = new GlideDateTime(); gdt.addDays(6);gdt.getDate(); and after the field appears on the form is still blank

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2022 01:02 AM - edited 11-22-2022 01:03 AM
This should work for you: javascript: var gdt = new GlideDateTime(); gdt.addDays(6);gdt.getDate();
Hope it helps.
Please mark my response as helpful or correct based on the impact