Is it possible to override State Model transitions through a script (e.g., BR or FS)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
We are currently using a State Model to control state transitions on the Problem table.
However, we have a requirement where we are updating the State using a Fix Script / Business Rule.
Due to the configured State Model, the update is being restricted and the record is not moving to the intended state.
So, I want to understand:
- Is it possible to bypass or override State Model restrictions through scripting?
- If yes, what is the recommended approach to achieve this?
setWorkFlow(false) - This is not working,
Any guidance or best practices would be helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @Sathwik1
Refer KB0759295 :System enforces the state transition (through com.snc.state_model.StateTransitionValidator) and does...
Issue
When the State Model and Transitions are enabled on a table ,System enforces the state transition (through com.snc.state_model.StateTransitionValidator) and does not allow transition of state through Business Rule / Script, if it does not validate against existing model transition.
Cause
This is an expected behavior as designed, The state transition will be enforced as configured for the table. System will not allow any invalid state transition on the record through the UI or script.
Please review > Add a state model and transitions
Resolution
If you want to allow the update on the state , through Business Rule / API Script, the following System property can be used to disable the "StateTransitionValidator"
com.glide.record.state.validation = false
If the property above is disabled system will not validate and allow transition to any state on the record that is done through the script / business rule.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hello @Sathwik1 ,
Try adding :
gr.setUseEngines(false);
as per my understanding when updating a record via GlideRecord, you can use this to bypass data policies, and in some contexts, it can allow bypassing state validation by skipping the business rules that enforce the model.
Also if this is a one-time data fix, use StateModel.forceUpdate().
If this is a recurring requirement (an integration updating the problem), you should actually update the State Model to allow that transition, but add a condition so it only triggers when the user is "System Administrator".
Also have a look on this :
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0861927#:~:text=Issue,Schedul...
If my response helped mark as helpful and accept the solution.
