Sending email notification after group has been deleted
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-01-2024 09:23 PM
Error: getEventTarget() called with invalid record reference: sys_user_group.d477df9c976f791035ddbfb6f053affd for event: delete.notification.registry, could have been deleted.
PS: I have created a business rule - applied when to run as 'before' , 'delete'
The business rule is as follows:
(function executeRule(current, previous /*null when async*/) {
try {
// Set up incident record
var incidentGR = new GlideRecord('incident');
incidentGR.initialize();
incidentGR.setValue('short_description', 'Group Deleted: ' + current.name);
incidentGR.setValue('assignment_group', '12a586cd0bb23200ecfd818393673a30'); // incident management group
incidentGR.setValue('caller_id', '6816f79cc0a8016401c5a33be04be441'); // system administrator
var sysID = incidentGR.insert();// fetch sysid of created incident
// Fetch incident number
var gr = new GlideRecord('incident');
if(gr.get(sysID)){
// Send email notification
var groupName = current.name;
var incidentNum = gr.number;
gs.eventQueue('delete.notification.registry', incidentGR,groupName, incidentNum);
}
} catch (ex) {
gs.error('Error in business rule: ' + ex);
}
})(current, previous);
Could someone help me with it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2024 07:44 AM
Do not provide the group name because group will not be existing after it is deleted, however I would suggest get the group members list in an array and pass that array in the event parameter so that it has no dependency for group while it sends the notifications
Hope that helps