Stop removing Incident associations from a Closed prb record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2024 03:14 AM
I am an ITIL user working on a Problem record (B) in an active state.
I navigate to the 'Incidents' related list AND add (left to right slush bucket) the incidents that has a currently closed Problem record (A) on the problem field.
The system will not add the Incident association to the 'Incidents' related list of Problem Record (B)
How to achieve this functionality?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2024 03:33 AM
To achieve the functionality where you want to add incidents associated with a currently closed problem record to the related list of another active problem record, I think you can implement this functionality in a business rule that runs when a new problem record (B) is created or when a problem record transitions to an active state.
// Business Rule Name: Associate Incidents with New Problem
// Table: Problem [problem]
// When: After
// Insert: false
// Update: true
// Condition: state changes to Active
(function executeRule(current, previous /*, other*/) {
// Check if the problem record transitioned to Active state
if (current.state == '2' && previous.state != '2') { // '2' represents the Active state
// Query for incidents associated with closed problem record (A)
var gr = new GlideRecord('incident');
gr.addQuery('problem', 'problem_A_sys_id'); // Replace 'problem_A_sys_id' with the sys_id of the closed problem record
gr.query();
// Loop through the incidents and update their problem field to associate them with the new problem record (B)
while (gr.next()) {
gr.problem = 'problem_B_sys_id'; // Replace 'problem_B_sys_id' with the sys_id of the new problem record
gr.update();
}
}
})(current, previous);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2024 03:43 AM
I think we need to use Before Update BR, as we need to abort the action.