get date/time when state = resolved

Tyler36
Tera Contributor

When the state = resolved i have a business rule that is running and setting the resolved by field to the user. I need it to also get the date and time when it was resolved. Then after it gets the date i need to set the field "closed" to 2 days after the state = resolved. Any ideas on how to do this?

8 REPLIES 8

Prateek kumar
Mega Sage

You have a system property to autoclose resolved incidents.

Check below:

https://docs.servicenow.com/bundle/london-it-service-management/page/product/incident-management/tas...


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Tony Chatfield1
Kilo Patron

Hi, you should be able to use the dateTime functions - something like

 

var myTime = new GlideTime();

gs.info("Current system Time " + myTime);

myTime.addDaysLocalTime(2);

gs.info("updated time " + myTime);

Sumanth16
Kilo Patron

Hi tyler ,

 

Create "custom field" on your table and create before business rule on that table with condition state is resolved.And populate "sys_updated_on" value into "custom field".

 

Then after create a scheduled job with condition resolved relatively 2 days ago and run the scheduled job periodically to update the state to closed complete.

 

Please mark it as helpful (or) correct if it helps.

 

Thanks,
Sumanth 

asifnoor
Kilo Patron

Hi,

In the existing Br, add this code.

//When the state = resolved i have a business rule that is running and setting the resolved by field to the user. I need it to also get the date and time when it was resolved. Then after it gets the date i need to set the field "closed" to 2 days after the state = resolved. Any ideas on how to do this?

var gdt = new GlideDateTime();
current.u_resolved_time=gdt;//this field u_resolved_time will store the resovled date and time. create this field of type date/time.
gdt.addDays(2);
current.u_closed=gdt;//this field u_closed will store the closed date.

Kindly mark the comment as a correct answer and helpful if it helps to solve your problem.

Regards,
Asif
2020 ServiceNow Community MVP