- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 06:55 AM
Hello experts,
I created a business rule that creates automatically a “change request” from RITM.
Then I created another business rule that does the following : when the change request state changes to “assess” , the related RITM updates to “work in progress” : the problem is my script is not working : when I update a chg request, the related RITM didn't get updated ! I tried to fix it with chatgpt but it didn't work :
(function executeRule(current) {
if (current.state == 3) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('sys_id', current.parent);
ritm.query();
if (ritm.next()) {
ritm.state = 2;
ritm.update();
} else {
gs.error('RITM not found ' + current.sys_id);
}
}
})(current);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 08:25 AM - edited 03-19-2025 08:30 AM
Hi @yasserbouat
add this code :
chg.parent = current.sys_id;
after - chg.priority = current.variables.v_priority.toString();
Then try to test it and check it parent field on change request form is updated or no.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 08:25 AM - edited 03-19-2025 08:30 AM
Hi @yasserbouat
add this code :
chg.parent = current.sys_id;
after - chg.priority = current.variables.v_priority.toString();
Then try to test it and check it parent field on change request form is updated or no.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 09:07 AM
@Dhana3
I added the line as you suggusted, and I create a request and I opend the xml and I found the parent, then i updated the change state to assess, but the related RITM didn't get updtaed ! and i also noticed an error on the portal :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 11:03 PM
Hi @yasserbouat ,
This issue is with your change model configuration. But that is a different issue.
Please check this documentation - https://www.servicenow.com/docs/bundle/yokohama-it-service-management/page/product/change-management...
I suppose you are new to ServiceNow development. I suggest you to do through the documentation and learn about scripting. It is not that difficult.
All the best!
Regards,
Dhanashree
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 08:11 AM
@Dhana3
This is what I got : can you please show what should i do in order to make my script functions :
<order/>
<outside_maintenance_schedule>false</outside_maintenance_schedule>
<parent/>
<phase>requested</phase>