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 10:06 PM
HI sandeep,
The provided script is not working in a business rule. Can you please tell whats' wrong with it. I have updated the correct event.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2023 11:14 PM
@sanga2 Could you please provide screenshot of your business rule
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 02:42 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 03:50 AM
Hi @sanga2 ,
I trust you are doing great.
- Create a new Business Rule on the HR case table (e.g., "Avoid First Comment Update Notification").
- Set the Business Rule's "When to run" to "Before" so that it runs before the record is updated.
- In the "Advanced" section of the Business Rule, write a script to check if the "comments" field has been modified.
- If the "comments" field has changed, retrieve the previous comments from the record's previous state.
- Check if the previous comments were empty, indicating that it's the first comment update.
- If it's the first comment update, set a condition to prevent the notification from being triggered.
- Save the Business Rule.
Here's a sample script for the Business Rule:
(function executeRule(current, previous /*, g*/) {
// Check if the "comments" field has changed
if (current.comments != previous.comments) {
// Check if previous comments were empty (indicating first comment update)
if (!previous.comments) {
// Set the condition to prevent the notification from being triggered
current.setAbortAction(true);
}
}
})(current, previous);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2023 04:32 AM
Hi Amit,
Thanks for the response and suggestion. I just want to highlight here that the comments field here is a 'journal input' type field. will the above script work in that scenario as well?
Thanks.