- 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 07:14 AM
Hi @yasserbouat ,
You need to debug if your 2nd BR is getting triggered or not. Use Add Message to determine the same.
Also when a change Request is getting created from RITM, then in the RITM parent filed the newly created CR is getting mapped?
Also make below changes in the 2nd BR
(function executeRule(current) {
if (current.state == 3) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('parent', current.sys_id); // Changes here
ritm.query();
if (ritm.next()) {
ritm.state = 2;
ritm.update();
} else {
gs.error('RITM not found ' + current.sys_id);
}
}
})(current);
If my response helped, please hit the Thumb Icon and accept the solution so that it benefits future readers.
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 07:21 AM
Hi @yasserbouat ,
Have you checked what is stored in parent field on change request table? Depending on that value you need to modify the code. There are lot of ways which you can verify your script. Use background script, add info message or add logs in your script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 07:33 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2025 07:51 AM - edited 03-19-2025 07:51 AM
Hi @yasserbouat ,
Click on the hamburger menu on the change form, click on show xml and search for parent there. Tell me what value it has.