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

Ankur Bawiskar
Tera Patron
Tera Patron

@Vinod S Patil 

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.

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

@Ankur Bawiskar 

Thank you for the suggestion:)

Notification is triggering even if I update test in work note which is not expected.


@Vinod S Patil 

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.

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

@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;