How should I set to enter "Planned start date + 2hours" in the Change Task(change_task)'s DueDate?

ayano
Giga Guru

What settings will make the Change Task (change_task)'s DueDate auto-fill?

 

I want to set to enter "Planned start date + 2hours" in the Change Task(change_task)'s DueDate.
How should I set?

 

 

7 REPLIES 7

Anil Lande
Kilo Patron

Hi,

Please check below:

https://www.youtube.com/watch?v=t9MISYRfu8o

https://www.servicenow.com/community/developer-forum/adding-date-to-current-date/m-p/1674246

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
You can write a BR onBefore insert.

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var psd=new GlideDateTime(current.planned_start_date);
	psd.add(3600000);
current.due_date=psd;
})(current, previous);

 




Thanks and Regards,

Saurabh Gupta

Hi @Saurabh Gupta  
Thank you for your comment.
What does "3600000" mean?

Thanks anf Regards,

Hi Ayano,

 

This is the time unit we are giving as 3600000ms. It means 60min*60sec*1000. for 2 hrs you can use 7200000.

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Pankaj Kumar