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 06:33 AM - edited ‎07-07-2025 07:04 AM
update as this if you want to query in incident table and see if the actual incident number is present
var str = current.work_notes.getJournalEntry(1);
var regex = new SNC.Regex('/INC\\d{7}/im');
var match = regex.match(str);
// query incident table
var gr = new GlideRecord("incident");
gr.addQuery("number", match);
gr.setWorkflow(false);
gr.query();
var isIncidentPresent = gr.hasNext();
if (str.indexOf('file share failed') > -1 && isIncidentPresent) {
answer = true;
}
answer = false;
Update as this if you don't want to check if the INC is actually present but INC number is just present
var str = current.work_notes.getJournalEntry(1);
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 06:53 AM
@Ankur Bawiskar
Thank you for the suggestion:)
Notification is triggering even if I update test in work note which is not expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2025 06:53 AM
did you add logs and see?
which code you are using the 1st or 2nd?
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 06:55 AM - edited ‎07-07-2025 06:55 AM
@Ankur Bawiskar
I am using second code
var str = current.work_notes.getJournalEntry(1); var regex = new SNC.Regex('/INC\\d{7}/im'); var match = regex.match(str); if (worknotes.indexOf('file share failed') > -1 && match != null) { answer = true; } answer = false;