Active Incident is not setting to false after Incident state got Cancelled

zee15
Tera Contributor

Hi 

I created a fix script to cancel incident records and used setWorkflow(false) within the script.

zee15_0-1754656486837.png

 

When I executed it, the incidents were marked as "Cancelled," but they all remained active due to the setWorkflow(false) setting.

Now, I'm trying to set the active field to false, but it’s not working. Even when I manually or by script try to update the field, it automatically reverts back to true.

Can anyone help me understand what might be causing this behavior? Also, what would be the correct way to make all these incidents inactive now?

Thank you for your help

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@zee15 

My thoughts

-> you just set the state field in your fix script and not incident_state 

-> there is this business rule "incident reopen" which marks the active field = true when you try to set the active=false

-> the BR condition is this

current.incident_state != IncidentState.CLOSED && current.incident_state != IncidentState.CANCELED

-> since you didn't update incident_state field the BR condition gets satisfied and it reverts active flag

-> Did you try to re-run the fix script to mark active=false and please use setWorkflow(false)

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

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@zee15 

My thoughts

-> you just set the state field in your fix script and not incident_state 

-> there is this business rule "incident reopen" which marks the active field = true when you try to set the active=false

-> the BR condition is this

current.incident_state != IncidentState.CLOSED && current.incident_state != IncidentState.CANCELED

-> since you didn't update incident_state field the BR condition gets satisfied and it reverts active flag

-> Did you try to re-run the fix script to mark active=false and please use setWorkflow(false)

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