How to set an Condition in the notification (sys_notification)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2024 03:22 AM
Hi All,
We have a notification that is being generated and displayed in the agent workspace.
The filter condition is set to "State Changes," and the notification is being triggered for all state changes.
However, our requirement is that the notification should not be generated when the state changes from Resolved to Closed.
Help me,
Thanks
Nagarjuna
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2024 03:50 AM - edited ‎11-07-2024 11:58 PM
Hello @DNC
This can be achieved by adding the code in advanced condition in the notification.
// Check if the notification should be sent
(current.state.changes() && !(current.state == 'Closed' && current.state.changesFrom('Resolved')));
Refer the screenshots of notification configuration:
- If advanced condition field is not visible, configure the form layout.
- This will trigger the notification whenever the state changes except when the state changes from Resolved to Closed.
This solution is tested in my PDI and it works.
"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2024 03:54 AM
Hi @DNC ,
you can try below way to achieve this
1 create an event by following this steps
in navigation type event then click on Registry
then click on new fill name and table
then goto notification update the when to run section like below
who will receive like this
then goto Business rule create After update business rule
script
(function executeRule(current, previous /*null when async*/) {
if (current.state == '7' && previous.state == '6') { // 7 is closed and 6 is Resolved
// If the state is changing from Resolved to Closed, do not send the notification
return;
}else{
gs.eventQueue("state.changes",current,current.caller_id);
}
})(current, previous);
it will not trigger the notification if state changes from Resolved to Closed.
Please mark helpful & correct answer if it's really worthy for you.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2024 03:55 AM
Hi @DNC ,
Simple use below condition, i have tested it, its working.
-------------------------------------------------------------------------
If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.
Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay
-------------------------------------------------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-07-2024 11:17 PM
@Runa Yes, It is working, But our requirement is if the Incident is moving from Resolved to Closed only, we need to stop that notification.
But, our changes are stopping the notification if the incident is moving from WIP, On Hold to Closed.