Advance condition notification is not working

Vinod S Patil
Tera Contributor

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:

VinodSPatil_1-1751894708913.png

 


Work notes:

VinodSPatil_0-1751894670413.png



@Ankur Bawiskar 
@Shubham_Jain 

 

8 REPLIES 8

@Vinod S Patil 

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.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

script I am using:

var str = current.work_notes.getJournalEntry(1);
 
//var regex = new SNC.Regex('/INC\\d{7}/i');
var regex = /\bINC\d{7}\b/i;
 
var match = regex.match(str);
 gs.info(str);
if (worknotes.indexOf('file share failed') > -1 && match != null) {
    answer = true;
}
answer = false;


and the log

VinodSPatil_0-1751898578532.png

 

GlideFather
Tera Patron

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! */


Shubham_Jain
Mega Sage

@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