State model - Can change state? business rule

kunal16
Tera Expert

There is a business rule called 'State model - Can change state?' which can be seen across ServiceNow platform since last April after the Geneva Patch 3 Hotfix 2 upgrade. This business rule runs for the change request table (Before-Insert). Do anyone knows what this business rule does? I can see that this rule is calling a script include ChangeRequestStateHandler which in turn calls another Read-Only script include ChangeRequestStateHandlerSNC but couldn't understand the logic.

Thanks in advance!!

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);

}

6 REPLIES 6

Nirupam Biswas
ServiceNow Employee
ServiceNow Employee

This business rule validates if the current state transition in Change Request is valid. If not then it aborts it.



For example, if for a normal Change if you are moving from Assess to Authorize state, then the following code will be invoked.



      ChangeRequestStateModel_normal.assess.authorize.canMove();



which in-turn invokes:-



  ChangeRequestStateModelSNC_normal.toAuthorize_canMove();



Which returns 'true' so it will go through.


I've an issue where keeping this BR active, it makes my normal BR jump from assess to scheduled state.   I undid changes made to ChangeRequestStateModel_normal but still seeing this issue.   Any solution to this?


Hi Nirupam,

I have to close an CR from background script which is currently in 'Assess' State. But this BR is preventing me from doing so. Any suggestions on how to change the state of the CR?

Hi Nirupam,

I have to close an CR from background script which is currently in 'Assess' State. But this BR is preventing me from doing so. Any suggestions on how to change the state of the CR?

Thanks in advance!