State model - Can change state? business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2016 03:19 AM
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);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2023 06:52 AM
Technically you can use `setWorkflow(false)` to turn off BRs from running. However, since this BR is preventing that update then as per it the change you are trying to make is invalid. So, not sure what is your exact use-case because of which you forced to fight the state model validation.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2023 07:10 AM
Thanks Nirupam! It works.