- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2020 06:41 AM
I would like to know if anyone can help me with figuring out how to update secondary records.
I have the following script that will update the parent record (all records are parent unless the parent field is filled in) I need to find all secondary records and set the u_triage_sla_time on them. But not sure how to accomplish that.
(function executeRule(current, previous /*null when async*/) {
var parentID = current.sys_id;
var tableName = 'em_alert';
//var assignedTo = current.u_assigned_to;
var gdt = new GlideDateTime(new Date());
var emAlert = new GlideRecord(tableName);
emAlert.addQuery('sys_id',parentID);
emAlert.query();
while (emAlert.next()){
//gs.info('@@@ UpdateTriageTime completed at ' + gdt);
emAlert.setValue('u_triage_sla_time',gdt);
emAlert.update();
}
})(current, previous);
Need to do with this script:
1. Find any other record in the em_alert table that has the parent field the same as the current sys_id (all child records) I can do the update part just need to know how to find all child (secondary) alerts.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2020 08:35 AM
Hi Steve,
It's an alert management rule sorry, not a maintenance rule...too many things beginning with M for a Friday.
Maintenance rules can run when a record changes to a value or is created with a set of values. They can then run subflows (which this will) automated actions to automatically resolve issues or allow manual operations via the "Quick Action" of an operator.
1. Create a new Alert Management Rule with a clear name
2. Set the filter to run when the alert record changes to meet the condition of Acknowledged = True & Role is Primary
3. Save the record, it'll show an alert saying it's moved to in-active as it doesn't have an action. We'll make that next
4. Open Flow Designer and navigate to 'Subflows' and find the Alert Management Template record. Open it
5. Using the action menu copy the flow and give it a name
6. Our first action is to update the alert record. We use the 'Update Record' action and the input->alertGR data pill for the record. Sadly Flow doesn't have the ability to set the time to the current time as of yet, so we need to use the inline script feature.
7. We then do a 'Look Up Alert Records' to find all the child records.
8. We then add a if statement to check we have some records. If we don't, and for whatever reason the lookup returns 0, the flow will error.
9. We then add a 'For Each Item in' to update all the secondary records.
10. And again, same as the first update record. Save & Publish your creation
11. Go back to the alert management rule and update the 'actions' section with the subflow created. I've set it to run automatically once. Also need to set the rule to active.
And that should be that. If you're not feeling like doing the above, I captured what I did in an update below 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-25-2020 09:39 AM
Glad it worked! Once you get your head around alert management and flow designer you start to see the power of the platform 😄
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2020 08:37 AM
Do you know if you can use the same thing for sn_si_incidents?
I have the need to do basically the exact same thing

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2020 09:04 AM
Hey Steve,
I've not done much with SIR or any of the SecOps modules. You won't be able to use alert management rules as these are specific to ITOM Event Management but the concept of flow designer could be used AFAIK.