Email getting triggered multiple times for same notification
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2024 03:45 AM - edited ‎06-04-2024 03:47 AM
Hi Team,
I need inputs to check an issue in lower instance. An email is triggering multiple times(more than 5) for the same notification. It is happening across all the notifications which is configured. there is 1 schedule job 1 email script 1 event for all 4 notifications.
The conditions are good and many mails are triggering within a sec difference.
Kindly let me know what could be the issue.
Thanks for the reply in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2024 04:31 AM
Please share your code. Without that it is guessing. Probably the scheduled job is triggering the event multiple times.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2024 05:21 AM
Try this:
// Create an Array of Escalations
var escArr = [
{ type: 'first', query: 'short_description=IRM SOX Control Remediation Task^sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()' },
{ type: 'second', query: 'short_description=IRM SOX Control Remediation Task^sys_created_onONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()' },
];
// Consolidate Escalations Processing
var uniqueQueries = {};
for (var esc in escArr) {
var escObj = escArr[esc];
if (!uniqueQueries[escObj.query]) {
uniqueQueries[escObj.query] = [];
}
uniqueQueries[escObj.query].push(escObj.type);
}
for (var query in uniqueQueries) {
var types = uniqueQueries[query];
var taskRec = new GlideRecord('sc_task');
taskRec.addEncodedQuery(query);
taskRec.query();
while (taskRec.next()) {
for (var i = 0; i < types.length; i++) {
var escType = types[i];
var evtObj = {
escalation: escType,
eventUsers: null
};
if (escType == 'first') {
evtObj.eventUsers = taskRec.cmdb_ci.u_technology_ci_owner.manager.getValue();
}
if (escType == 'second') {
evtObj.eventUsers = taskRec.cmdb_ci.u_technology_ci_owner.manager.manager.getValue();
}
// Process the Event
gs.eventQueue('syf.sox.escalation', taskRec, evtObj.eventUsers, JSON.stringify(evtObj));
}
}
}
function _createIncident(taskRec) {
// Create a value to return
var incNum = '';
var incVals = _getIncidentValues(taskRec);
var incRec = new GlideRecord('incident');
// Check for existing Incidents
incRec.addActiveQuery();
incRec.addQuery('u_service_request', incVals.u_service_request);
incRec.query();
if (incRec.next()) {
return null;
} else {
// Create a new Incident
incRec.initialize();
// Set values based on the Task
for (var val in incVals) {
var incCol = val;
var incVal = incVals[val];
incRec.setValue(incCol, incVal);
}
if (incRec.insert()) {
incNum = incRec.getValue('number');
}
return incNum;
}
}
function _getIncidentValues(taskRec) {
// Create a Map of value object properties
var valMap = {
'assigned_to': taskRec.cmdb_ci.u_technology_ci_owner.getValue(),
'assignment_group': taskRec.getValue('assignment_group'),
'caller_id': taskRec.request.requested_for.getValue(),
'cmdb_ci': taskRec.getValue('cmdb_ci'),
'opened_by': taskRec.request.requested_for.getValue(),
'u_service_request': taskRec.getValue('request_item'),
'category': "Authentication\\Authorization",
'description': "Terminated users with access to CI since past 4 weeks" + '\n' + taskRec.getValue('description'),
'priority': "2",
'short_description': "Non-SIAM ACL/SOX Control Remediation",
'subcategory': "change privileges/right",
'urgency': "2"
};
// Return the Map
return valMap;
}
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2024 07:38 AM - edited ‎06-04-2024 07:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-04-2024 08:54 AM
it is not working