- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 07:19 AM
Hello,
I want to create a change request automaticaaly from RITM when this one is created, and in order to do that I created a business rule as the following but it is not working :
Script :
(function executeRule(current) {
var chg = new GlideRecord('change_request');
chg.initialize();
chg.type = current.variables.model.toString();
chg.category = current.variables.category.toString();
chg.short_description = current.variables.short_description.toString();
chg.priority = current.variables.priority.toString();
// Ensure service reference is valid
if (current.variables.service) {
chg.cmdb_ci = current.variables.service;
}
chg.state = 1; // Optional: Defaults to "New"
var chgSysId = chg.insert();
if (chgSysId) {
gs.info('Change Request ' + chgSysId + ' created from RITM ' + current.sys_id);
} else {
gs.error('Failed to create Change Request from RITM ' + current.sys_id);
}
})(current);
and the mapping must be with the variables in RITM : Model - Category - Short description - Priority - service.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 08:00 AM
your script is fine.
Did you check variable names are correct?
Did you add log at each line and see which line is breaking?
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
03-18-2025 07:48 AM
Hi @yasserbouat , are you not seeing the info message or your change request is not getting created? Your script seems fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 07:56 AM
@GopikaP thanks for your reply : the change request is not getting created !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2025 08:00 AM
your script is fine.
Did you check variable names are correct?
Did you add log at each line and see which line is breaking?
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
03-18-2025 08:23 AM
@Ankur Bawiskar you were right about variable names : some of theme has v_name (service => v_service ... ) : thanks very much