Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Cancelling an incident

John Vo1
Tera Guru

When I cancelled an incident it marks the Closed field at 11/26/2019.

find_real_file.png

 

So if I reopen that incident the Closed info is still showing 11/26/2019 and when I actually close out the incident it will still show the same 11/26/2019.  So now if managers what to run reports on that the time and dates will not be correct.  So how do I get it to where when it's cancelled the Closed field is not populated?

1 ACCEPTED SOLUTION

Try with this code:

if (current.closed_at.nil() && current.incident_state == IncidentState.CLOSED)
		current.closed_at = gs.nowDateTime();

Basically it will populated the Closed date/time field only in case of Incident closure and NOT in case of Incident cancellation.

If I have answered your question, please mark my response as correct and/or helpful.

Thank you very much

Cheers
Alberto

View solution in original post

12 REPLIES 12

Anurag Tripathi
Mega Patron
Mega Patron

Hi John,

 

You can write a script(BR Mostly) to clear out the closed field when incident is reopened. That should fix the issue.

 

-Anurag

-Anurag

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi John,

if you want to change this behavior, you need to change the Business Rule mark_closed in the Incident table, especially you have to change this part of code:

if (current.closed_at.nil())
		current.closed_at = gs.nowDateTime();

find_real_file.png

If I have answered your question, please mark my response as correct and/or helpful.

Thank you very much

Cheers
Alberto

So what would the new code look like? I'm not to proficient at JS.

Try with this code:

if (current.closed_at.nil() && current.incident_state == IncidentState.CLOSED)
		current.closed_at = gs.nowDateTime();

Basically it will populated the Closed date/time field only in case of Incident closure and NOT in case of Incident cancellation.

If I have answered your question, please mark my response as correct and/or helpful.

Thank you very much

Cheers
Alberto