Roney Stones
Roney Stones

Reputation: 3

How to automatically change the Incident state after "Create Normal Change" action?

I would like to set the state to "Awaiting Change" when a Change is created from the incident using "Create Normal Change" or "Create Emergency Change" UI action.

Upvotes: 0

Views: 3326

Answers (2)

Here’s how you can achieve this:

  • Disable the "On Hold" State Choice:

Navigate to the "On Hold" choice in the "State" field and set the "Inactive" field to true.

  • Add the "Awaiting Change" State Choice:

You mentioned you have already created the "Awaiting Change" state. Ensure you have set the Value field to 4 in the sys_choice record.

  • Update the UI Actions:

To set the state on the incident record to "Awaiting Change" when a change is created from an incident, you need to update the "Create Normal Change" and "Create Emergency Change" UI actions.

Insert the following code just after the line

changeRequest.insert();

changeRequest.setValue("state", 4);
current.update();

Note: Replace 4 with the actual value you set for "Awaiting Change" if it's different.

Here’s a detailed step-by-step guide for updating the UI actions:

  • Go to the UI Actions section in the ServiceNow instance.

  • Find and open the "Create Normal Change" UI action.

  • Locate the line:

  • List item

    changeRequest.insert();

Directly after this line, insert:

changeRequest.setValue("state", 4); // Replace 4 with your actual value 
current.update();

Repeat the same for the "Create Emergency Change" UI action. This should ensure that the incident state is updated to "Awaiting Change" whenever a change record is created from an incident.

Hope this helps!

Upvotes: 0

Kirk
Kirk

Reputation: 16255

When you create a change from either of those UI Actions, the Change Request field is populated with a reference to the one that was generated.

You can create a Business Rule for this that triggers when this happens. You can change the State once the Change Request field changes.


Name: Change Created

Table: Incident

When to run

Update: checked

Filter Conditions:

  • Change Request changes
  • -- and -- Change Request is not empty

Actions

Set field values

  • State To On Hold
  • On hold reason to Awaiting Change

Something like this

enter image description here

Upvotes: 0

Related Questions