After Rejected, Change Request State should be be 'Closed' not 'New'

Servicenow10
Kilo Guru

My requirement is that if at any approver rejects the Change Request, the state should become 'Closed' instead of 'New'. I tried it using workflow but not able to achieved.............

if an approver rejects the change request it should be closed with a comment because of approvers rejection it is closed 

1 ACCEPTED SOLUTION

Hi,

Here is how you can do this. I checked in my PDI and its working fine.

After reject notification, in your WF, add run script activity.

In run script, add the following code.

current.setWorkflow(false); //This will disable the BR that is restring the state move.
current.close_notes = "rejected";
current.close_code = "unsuccessful";
current.state = 3;

Connect Reject notification -> Run script -> End.

Mark the comment as a correct answer and also helpful once worked.

View solution in original post

21 REPLIES 21

Moy1
Kilo Guru

In an OOB instance, some restrictions are applied on the state transitions on change_request records. Check under state management>state.

https://docs.servicenow.com/bundle/newyork-it-service-management/page/product/change-management/concept/c_ChangeStateModel.html

can you please help me with this BR : State Module-Can change state

if i disabled this it goes to closed after rejection but this will affect other implications or not.

 

 

Hi,

Kindly share the BR and we can place a condition to run only for your CRs and not to others.

Is there any pattern to identify/separate your created CRs from other CRs. (ex: assignment group, or category or anything)

hi asifnoor

actually this one is pre-defined br so making any changes to it will affect other things or not?

 

table is change_request

when to run before update

condition: state changes

advanced script:

function onBefore(current, previous) {
var stateHandler = new ChangeRequestStateHandler(current);

// Check if the change in state that has already occured is valid
if (!stateHandler.moveFrom(stateHandler.getStateName(previous.state)))
current.setAbortAction(true);


}

 

if approver reject this then state should be closed closed code-unsuccessful and close notes should be due to approvers rejection chgq req closed.