- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 02:58 AM
Hello, is there an equivalent to the IncidentState script include for change management?
When updating incident state values (e.g. in a business rule), it is recommended to use "IncidentState.CLOSED" instead of '7'.
Within change management I couldnt find a similiar script include. So I assume I have to hard coded the state value into my business rule or does anyone know about a best practice alternative?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 03:10 AM - edited 05-21-2025 03:16 AM
Hello @Tim Noack ,
There is no equivalent Script Include for Change Requests out of the box.
But this does not mean you have to hard code the state values in your logic. You could simply create your own Script Include, based on IncidentStateSNC but adjusted for the Change Request states.
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 03:07 AM
you can define constants similar to what's present for incident or hard-coded as per your requirement.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 07:37 AM
Are there any out of the box constants?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 08:02 AM
Hello @Tim Noack ,
That question is equivalent to asking if there is a Script Include like IncidentState.
It's the Script Include that is defining these constants, so that you don't have to deal with the internal value numbers.
But as mentioned there is no such Script Include for Change Requests.
You can create it yourself. It's just a simple list of constants.
var ChgState = Class.create();
ChgState.NEW = "-5";
ChgState.ASSESS = "-4";
ChgState.AUTHORIZE = "-3";
// and so on...
ChgState.prototype = {
initialize: function() {
},
type: 'ChgState'
};
Then you can use it in your scripts, like:
var grChg = new GlideRecord('change_request');
grChg.addQuery('state', ChgState.NEW);
...
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 08:35 AM
Something like this shared below
Universal Pattern for Script Includes
example like this
var MyConstantsUtil = Class.create();
MyConstantsUtil.prototype = {
CONSTANTS: {
STATUS_NEW: 'New',
STATUS_IN_PROGRESS: 'In Progress',
STATUS_COMPLETE: 'Complete'
},
initialize: function() {},
type: 'MyConstantsUtil'
};
Then call it from server side as this
var util = new MyConstantsUtil();
gs.info(util.CONSTANTS.STATUS_NEW); // Outputs: New
Output:
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader