Need to stop a notification through a business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 02:15 AM
Hi all,
We have setup a notification on the update of the additional comments on the hr case ticket. However, we have a requirement where in we need to avoid triggering this notification for the first comment that has been updated on the ticket.
I'm trying to trigger the notification through a business rule using the event trigger. Could you please help how can we achieve this functionality. it desnt matter who updated the first comments and what time (could be insert or update).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 04:19 AM
@sanga2 You can use below script to get the list of comments. Here you can write a logic like if number of comments (j.entries.length) is greater than 1 than only trigger event. You can put your table name instead of incident.
var j = new GlideSPScriptable().getStream("incident", current.sys_id);
if (j.entries.length > 1) {
write event trigger logic
}
You can run this in background script to see list of comments
var j = new GlideSPScriptable().getStream("incident", "a1ffe2c187333d04edba9370cbb35d1");
for(var m = 0; m < j.entries.length; m ++) {
gs.print(j.entries[m].field_label + " - " + j.entries[m].value + " - Added By " + j.entries[m].login_name + " - On " + j.entries[m].sys_created_on.toString());
}
Refer below article too
If I could help you with your Query then, please hit the Thumb Icon and mark as Correct !!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 04:56 AM
Hi Sandeep,
I want to write a business rule to achieve this. Please help.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 05:32 AM
@sanga2 Use below script in business rule. Add your event details in eventQueue method
(function executeRule(current, previous /*null when async*/ ) {
var getComments = new GlideSPScriptable().getStream(current.getTableName(), current.sys_id);
if (getComments.entries.length > 1) {
gs.eventQueue(add your events details);
}
})(current, previous);
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 05:48 AM
I have tried by updating the event queue, it didnot trigger the notification after multiple comments update. Please suggest.