Restrict to only one notification when RITM Additional Comments gets changed

chatsaurav19
Tera Contributor

Hi All,

 

I am trying to achieve a scenario when the notification should get triggered only once RITM additional comments gets populated from SCTASK. Presently when the fulfiller of the SCTASK is adding a comment in SCTASK the RITM Additional Comment is getting populated twice.   

 

chatsaurav19_0-1716970858231.png

 

I have written a BR where I am trying to restrict the second trigger of notification as shown below, but somehow it is not working ( perhaps of the if condition ) ? 

 

 

    var addCom = current.comments.getJournalEntry(1);
    gs.info("Additional Comments from RITM::: " + addCom);
    if (addCom.indexOf('Comment from Task') == 0) {
        var grScTask = new GlideRecord('sc_task');
        grScTask.addQuery('request_item', sysID);
        grScTask.setLimit(1);
        grScTask.query();
        if (grScTask.next()) {
            gs.eventQueue('Notify_Assignee_PFNA_RITM_Update', grScTask, grScTask.assigned_to.email);
        }
    } else {
        return;
    }

 Can someone please help ?

 

Regards,

Saurabh

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@chatsaurav19 

are you trying to sync comments between RITM and SC TASK?

I think it's going in some loop

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

Hi @Ankur , Yes it is in a loop. I have achieved this finally by changing the BR to "before" update.

 

Regards,

Saurabh