Link multiple change requests to an incident via rfc field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2024 01:04 AM
I want to link multiple change requests to an incident. I tried modifying the rfc field and make it list instead of reference, but it saves just one change. I know about the option to add a related list, but I still want the functionality between incident and change. Right now, there is a business rule that sets the state of the incident "work in progress" when the change is closed. So, i want to keep this and once all changes are close, put the state in "work in progress". Any idea how to do this and how to modify the field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2024 01:56 AM
Hello @diana_tat
- Modify the dictionary and change the type to List instead of reference.
- This will allow to select multiple change records.
- Modify the existing business rule as:
(function executeRule(current, previous /*null when async*/) {
// Ensure the 'rfc' field is populated (which holds multiple change request sys_ids)
if (!current.rfc) {
return;
}
// Get all the Change Requests in the 'rfc' field
var grChange = new GlideRecord('change_request');
grChange.addQuery('sys_id', 'IN', current.rfc); // Assuming 'rfc' stores sys_ids of related change requests
grChange.query();
var allClosed = true;
// Check if all Change Requests are closed
while (grChange.next()) {
if (grChange.state != 'Closed') { // Check if the state is not 'Closed'
allClosed = false;
break;
}
}
// If all Change Requests are closed, set the Incident state to 'Work in Progress'
if (allClosed) {
current.state = 'Work in Progress'; // Update this to the desired state
current.update();
}
})(current, previous);
​
This will check if all the change records attached are closed and then only update the state to 'Work in Progress'.
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-26-2024 02:57 AM
Hi, Thanks for the reply. I deactivated the ootb rfc field and i have created a new one and made it list type. It works, i am able to save multiple changes now. The only problem is that the BR is not working. I have this code