Calculating Due Date Based on Requested Date

ljschwaberow
Giga Expert

I've been reviewing the Using DurationCalculator To Calculate a Due Date - ServiceNow Wiki wiki article to figure out how to set the default for a Catalog variable 'Due Date' to three business days from the 'Requested Date' = javascript:gs.now(). I think I need to create a schedule to incorporate in the scripting that is provided in the wiki article but I'm not sure how to design one that defaults to three weekdays from now. I'm still not too comfortable with scripting to but I think that is what I need, does anyone have any advice?

1 ACCEPTED SOLUTION

andrew_venables
ServiceNow Employee
ServiceNow Employee

Sorry Lindsey, not having much luck here!



I've tested this and definitely got it this time...



You just need to add the below as a new line at the top of your script:


javascipt:



So it will look something like:


javascript:


// Get the datetime now


var nowGdt = new GlideDateTime();


...



Fingers crossed!


View solution in original post

12 REPLIES 12

Hi Lindsey,



Sorry I didn't read that you wanted to use it as a default value.



To make this work, remove the last line gs.log(...



And replace it with:



dueDateGdt;


I made your correction and still no change


find_real_file.png


andrew_venables
ServiceNow Employee
ServiceNow Employee

Sorry Lindsey, not having much luck here!



I've tested this and definitely got it this time...



You just need to add the below as a new line at the top of your script:


javascipt:



So it will look something like:


javascript:


// Get the datetime now


var nowGdt = new GlideDateTime();


...



Fingers crossed!


That worked! Thank you so much for your help


Hi Lindsey, feel free to mark correct and helpful responses on this thread