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

Tyler36
Tera Contributor

So i added this:

var gdt = new GlideDateTime();
gdt.addDays(2);
current.u_closed=gdt;//this field u_closed will store the closed date.

i made the field date/time like you said and still nothing is showing up. 

Hi,

Did you add those 2 new fields on the form and are they showing with data filled or empty?

add a gs.log message and check if the BR is executing or not.

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

Regards,
Asif
2020 ServiceNow Community MVP

Chaitanya Redd5
Tera Guru

Hi Tyler,

I believe the functionality you are looking for is already there OOB. When the state changes to resolve the Resolved field is updated with the current date and time(i.e. resolution date and time).

Also, Prateek already provided a link for the autoclose of the incident. Autoclose of incidents is done OOB by the scheduled job and the duration of autoclose is defined in the property "glide.ui.autoclose.time" OOB the value is 7 and resolved incidents autoclose in 7 days. If you want to close in only 2 days, you need to just set the value of property as 2.

Kindly mark my answer as Correct and Helpful based on the Impact.

Regards,

Chaitanya

Megha Padale
Giga Guru

Hi Tyler,

You can configure a system property to automatically close incidents that have been in Resolved state for a specified number of days. You can also specify the user who is mentioned by default in the Updated by field when an incident is automatically closed.

Refer this link,
 
 
If my answer is helpful, please mark answer as helpful and correct.
 
Thanks and regards,
Megha.