- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2025 11:47 PM
Hello Community !
I need create one new notification when the needs attentions is true on the sc_task
For this
Trigger condition: 1. state changes from Pending to Work in progress
2.Additional comments updated by customer/ not assigned to
3.Catalog type is SSR
Should I need to create a multiple events for each one of this three conditions, if so then how to implement that.
If not how to achieve this.
Looking forward for the working solution
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2025 01:09 AM
Don't use Event, let notification get trigger based on updated checkbox on sc_task table
for checking this -> 2.Additional comments updated by customer/ not assigned to
You can use advanced notification condition and script
Something like this and enhance it further
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 03:09 AM
then use toString() to compare and also use gs.getUserName() to get user ID at line 10
(function runMailScript( /* GlideRecord */ current, /* TemplatePrinter */ template,
/* Optional EmailOutbound */
email, /* Optional GlideRecord */ email_action,
/* Optional GlideRecord */
event) {
gs.info('userID7');
var comments = '';
var userId = gs.getUserName(); // Get the logged-in user ID
gs.info('userID9' + userId);
var requestorId = current.request_item.requested_for.user_name.toString();
gs.info('userID14' + requestorId);
var gr = new GlideRecord('sys_journal_field');
gr.addQuery('element_id', current.sys_id);
gr.addQuery('element', 'comments');
gr.orderByDesc('sys_created_by');
gr.query();
gs.info('userID14' + requestorId);
gs.info('created by' + gr.sys_created_by);
if (gr.next()) {
gs.info('userID25', +comments);
if (gr.sys_created_by.toString() == userId || gr.sys_created_by.toString() == requestorId) {
gs.info('userID23' + comments);
comments += gr.value + '\n';
}
}
gs.info("userID32" + comments);
template.print('The task ' + current.number + ' has been updated by the customer with below comments ' + comments + '\n');
})(current, template, email, email_action, event);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2025 06:57 AM
Hello @Ankur Bawiskar
Thanks for the solution, Mail is getting triggered
And in the body : The task (task number) has been updated by the customer with below comments [Append the comments added by customer] Display View Ticket and redirect it to our Support portal.
This should be content in the body. for the appending the comments, I have written a script , you can find it below :
Thanks for the solution, Mail is getting triggered
And in the body : The task (task number) has been updated by the customer with below comments [Append the comments added by customer] Display View Ticket and redirect it to our Support portal.
This should be content in the body. for the appending the comments, I have written a script , you can find it below :
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2025 07:01 AM
did you debug by adding gs.info() statements?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2025 08:33 AM
yeah @Ankur Bawiskar , it is working till the 2nd info.
Should I need to make any changes to script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-09-2025 09:09 AM
you need to dot walk requested_for to know the userID
gs.info('userID7');
var comments = '';
var userId = gs.getUserID(); // Get the logged-in user ID
gs.info('userID9'+userId);
var requestorId = current.request_item.requested_for.user_name;
var gr = new GlideRecord('sys_journal_field');
gr.addQuery('element_id', current.sys_id);
gr.addQuery('element', 'comments');
gr.orderByDesc('sys_created_on');
gr.query();
if(gr.next()) { // use IF
if (gr.sys_created_by == userId || gr.sys_created_by == requestorId) {
gs.info('userID23'+comments);
comments += gr.value + '\n';
}
}template.print('The task '+current.number +' has been updated by the customer with below comments ' + comments + '\n');
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2025 02:47 AM
Hello @Ankur Bawiskar
I made the changes you told and tried but still it is the same
in logs as well UserID23 is not coming up
Thanks,