I need to set the due date for the approvers

Hazel3
Tera Contributor

Hi,

I need to set the due date for the approvers for one hour. The below script i have used.

var gdt = new GlideDateTime();  
 gdt.add(1 * 60 * 60 * 1000); 
var dueDateString = gdt.getValue(); 
return dueDateString;
But the due date field in the approver table is showing empty and after one hour is passed it is still waiting in the "Ask for approval" action
Hazel3_0-1736234372719.png

Kindly help on this.

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@Hazel3 

you want to add 1 hour to current date/time and set

if yes then do this

you can use addSeconds() function and give 3600 seconds = 1hour

var gdt = new GlideDateTime();  
gdt.addSeconds(3600);
return gdt.getValue();

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

The approvers are getting triggered for both the scripts. But the due date is empty in the approval record and flow is still waiting even after due date is passed.

@Hazel3 

where are you using that script?

You didn't share the complete detail

What's your business requirement?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

I am using this script in the due date script field in the "ask for approval" 

Hazel3_0-1736239669260.png