Need to populate a due date field 14 days for current date

Nic Omaha
Tera Guru

Hello, I am combed through the community but I seem to be stuck on what is probably a very simple request. I need to get the due date on our requests to default out 14 days and then we can change it manually if need be. Everything I have seen doesnt seem to work. Any ideas?

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Hi Nicholas,



The easiest way would be with a before insert business rule.



var now = new GlideDateTime();


var twoWeeks = now.addDays(14);


current.due_date = twoWeeks;


View solution in original post

7 REPLIES 7

Chuck Tomasi
Tera Patron

Hi Nicholas,



The easiest way would be with a before insert business rule.



var now = new GlideDateTime();


var twoWeeks = now.addDays(14);


current.due_date = twoWeeks;


This doesn't seem to be working on a Date field.  (not Date/Time)

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Nicholas,



You can keep this as a default value javascript:gs.daysAgo(-14); in dictionary for the field "Due Date". Something like this.


Screen Shot 2016-06-01 at 8.10.02 AM.png



http://wiki.servicenow.com/index.php?title=GlideSystem_Date_and_Time_Functions#daysAgo.28int.29&gsc....


Hmm this doesn't seem to do anything when I try that.