Notification is triggering multiple times
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi Community,
In our current setup, the ServiceNow instance operates in the IST (Indian Standard Time) zone. A business rule was implemented to monitor incident creation for a specific domain. The rule triggers a notification when 25 incidents are created in a single day for a specific caller.
However, since our clients operate in the US/Eastern time zone, the notification logic needed to be aligned with their local time.
To address this, the business rule was updated to calculate the start and end of the day based on US/Eastern time, This ensures that the notification is triggered correctly when 25 incidents are created within the same calendar day as per US/Eastern time. But it is not working as expected. Sometimes it's triggering when 16th notification is created , sometimes its triggering when 25th notification is created . Sometimes it's triggering more than once in a single day ..
Can anyone please help on this?
Conditions : after insert , domain is xyz, caller is xyz
Script :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
@Ankur Bawiskar Currently, the event is being triggered twice in production yesterday with previous script , whereas it should only trigger once when the specified conditions are met. Would it be feasible to implement a flag within the script to verify whether the event has already been triggered for the day? I f yes can u please give script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
@Ankur Bawiskar please help on this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
@Dr Atul G- LNG @Ravi Gaurav @Hemanth M1 can anyone please help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
where will you maintain the flag?
also if the logic is correct in DEV then it should work fine in TEST, UAT, PROD
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hello i hope that can help
(function executeRule(current, previous) {
var easternTZ = "America/New_York"; // Recommended name
// Current time in UTC
var now = new GlideDateTime();
// Convert to Eastern Time
var nowEastern = new GlideDateTime(now);
nowEastern.setTZ(easternTZ);
// Extract yyyy-MM-dd in Eastern time
var dateStr = nowEastern.getLocalDate().toString();
// Build start and end of the Eastern day (always correct!)
var startOfDayEastern = new GlideDateTime(dateStr + " 00:00:00");
startOfDayEastern.setTZ(easternTZ);
var endOfDayEastern = new GlideDateTime(dateStr + " 23:59:59");
endOfDayEastern.setTZ(easternTZ);
// Convert both to UTC for querying sys_created_on
var startUTC = startOfDayEastern.getValue();
var endUTC = endOfDayEastern.getValue();
// Count incidents
var ga = new GlideAggregate('incident');
ga.addQuery('sys_domain', 'a028216e47ed51508b6b4537536d4383');
ga.addQuery('caller_id', '748b5c7f97071550d2ec73100153af73');
ga.addQuery('sys_created_on', '>=', startUTC);
ga.addQuery('sys_created_on', '<=', endUTC);
ga.addAggregate('COUNT');
ga.query();
if (ga.next()) {
var count = parseInt(ga.getAggregate('COUNT'), 10);
// Fire *once*, when hitting 25
if (count === 25) {
gs.eventQueue('it.checkmate.incident.limit.reached', current);
}
}
})(current, previous);
If you find this answer useful, please mark it as solution accepted/helpful
Massimiliano Micali
