Advance condition notification is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 06:27 AM
Hello Everyone
My requirement is to trigger notification when work note of the sctask updates 'file share failed' and incident number.
I trying with below script but its not triggering the emails, for the reference attached notification script and work note of the sctask.
Please suggest me on this.
Notification:
Work notes:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 07:03 AM
what value comes in str variable?
share logs
I updated the script now
var str = current.work_notes.getJournalEntry(1);
gs.info(str);
var regex = new SNC.Regex('/INC\\d{7}/im');
var match = regex.match(str);
if (str.indexOf('file share failed') > -1 && match != null) {
answer = true;
}
answer = false;
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
07-07-2025 07:30 AM
@Ankur Bawiskar
script I am using:
and the log
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 07:41 AM
Hi @Vinod S Patil, try to play with the trigger condition: [Work note] [Changes], perhaps modifying this could help retrigger it.
Debug tip - try the notification whether it is triggered for ANY work note for this "WN Changes", if so, then you can focus on the string from the work notes and play around.
Please let me know if you had chance to test this
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-07-2025 07:45 AM
@Vinod S Patil Use below condition in Notification
// Trigger only if 'file share failed' and 'INC' is mentioned in the latest work note
var newNote = current.work_notes.getJournalEntry(1); // Gets latest journal entry
if (newNote && newNote.toLowerCase().includes('file share failed') && newNote.toUpperCase().includes('INC')) {
true;
} else {
false;
}
let me know if it helps you.
✔️ If this solves your issue, please mark it as Correct.
✔️ If you found it helpful, please mark it as Helpful.
—
Shubham Jain