Hi Community we need help on the notification to trigger for the additional not to work notes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-07-2025 05:19 AM
Dear Community,
We have developed a script to handle notifications for SC tasks and RITM users. The script is designed to send notifications only when the SC task user and the RITM user are the same. However, there are existing notifications in place, which may also trigger additional notifications, leading to duplicates. As a result, our client has requested that duplicate notifications be avoided, ensuring that only one notification is sent under these circumstances.
The current functionality works as follows: if the SC task user and the current user are the same, the notification is not sent. This condition has been successfully implemented. However, the client has additional requirements regarding the handling of "Additional Comments" versus "Work Notes." Specifically:
- If the "Additional Comments" field changes and the user is the same for both the SC task and RITM, the notification should not be sent.
- If the "Work Notes" field changes and the user is tagged (for example, @Edith), the notification should be sent, even if the request user is the same as the SC task user.
To summarize, we need to configure the system such that notifications are restricted only when the "Additional Comments" field is modified and the users are the same. If the "Work Notes" are updated, notifications should still be sent, even if the request user is the same.
Could you please assist us with the configuration to meet these requirements?
Thank you.
sc_task
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-10-2025 11:37 PM
It sounds like you have a detailed script for handling notifications in ServiceNow, but you need to refine it to meet specific requirements regarding "Additional Comments" and "Work Notes." Here's how you can adjust your script to meet these requirements:
SC Task Notifications:
- Send notifications only if "Work Notes" are updated and the user is tagged.
- Do not send notifications if "Additional Comments" are updated and the users are the same.
RITM Notifications:
- Similar logic as SC Task for "Additional Comments" and "Work Notes."
Here's an updated version of your script:function shouldSend() {
if (current.table == 'incident') {
var grinc = new GlideRecord('incident');
grinc.get(current.document);if (grinc.u_portfolio.getValue() != gs.getProperty('portfolio.caf') && grinc.caller_id != current.user) {
gs.log("Notification Activity Stream Working fine. Either portfolio is not 'caf' or caller_id is not current user.");
return true; // Send notification
} else if ((grinc.u_portfolio.getValue() != gs.getProperty('portfolio.caf') && grinc.caller_id == current.user) || grinc.u_portfolio.getValue() == gs.getProperty('portfolio.caf')) {
gs.log("Notification Activity Stream blocked. Either portfolio is not 'caf' or caller_id is current user || Either portfolio is 'caf'");
return false; // Notification should not be sent
}
}else if (current.table == 'sc_task') {
var gr = new GlideRecord('sc_task');
gr.addQuery('number', current.title);
gr.addQuery('request.requested_for', current.user);
gr.query();
if (gr.next()) {
if (gr.isFieldModified('comments') && current.comments != '') {
return false; // Do not send notification for Additional Comments
}
if (gr.isFieldModified('work_notes') && current.work_notes.indexOf('@') != -1) {
return true; // Send notification for Work Notes if user is tagged
}
}
}else if (current.table == 'sc_req_item') {
var grreq = new GlideRecord('sc_req_item');
grreq.addQuery('number', current.title);
grreq.addQuery('requested_for', current.user);
grreq.query();
if (grreq.next()) {
if (grreq.isFieldModified('comments') && current.comments != '') {
return false; // Do not send notification for Additional Comments
}
if (grreq.isFieldModified('work_notes') && current.work_notes.indexOf('@') != -1) {
return true; // Send notification for Work Notes if user is tagged
}
}
}var liveGroupProfileGR = new GlideRecord("live_group_profile");
liveGroupProfileGR.setWorkflow(false);
liveGroupProfileGR.addQuery("document", current.document);
liveGroupProfileGR.addQuery("table", current.table);
liveGroupProfileGR.addQuery("type", "!=", "support");
liveGroupProfileGR.query();if (liveGroupProfileGR.next()) {
var liveGroupMemberGR = new GlideRecord("live_group_member");
liveGroupMemberGR.setWorkflow(false);
liveGroupMemberGR.addQuery("group", liveGroupProfileGR.getUniqueValue());
liveGroupMemberGR.addQuery("member", current.profile);
liveGroupMemberGR.addQuery("state", "!=", "inactive");
liveGroupMemberGR.query();if (liveGroupMemberGR.next()) {
return false;
}
}var SecurityManager = new SNC.LiveFeedSecurityManager();
return SecurityManager.canReadField(current.user, current.table, current.document, current.field_name);
}shouldSend();
This script ensures that notifications are sent only when "Work Notes" are updated and the user is tagged, while avoiding duplicate notifications for "Additional Comments" when the users are the same.
- Similar logic as SC Task for "Additional Comments" and "Work Notes."