Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to Set the Default Value in Date Field on Catalog Item for 5 days out?

Wendy Peterson
Tera Guru

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??

 

find_real_file.png

1 ACCEPTED SOLUTION

Matthew Smith
Kilo Sage

Hi Wendy

This should work for you: javascript: var gdt = new GlideDateTime(); gdt.addDays(5);gdt.getDate();

Hope it helps.

Matt

View solution in original post

4 REPLIES 4

Matthew Smith
Kilo Sage

Hi Wendy

This should work for you: javascript: var gdt = new GlideDateTime(); gdt.addDays(5);gdt.getDate();

Hope it helps.

Matt

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 Roethof
Tera Patron
Tera Patron

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

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn