Disable additional comments notification for ritm when added sctask comments.

suresh40
Tera Contributor

Hi All,

 

Disable additional comments notification for ritm when added sctask comments Added. I have written business rule  script to copy sc task comments in Ritm its working fine. Now my requirement while coping sctask comments to ritm no need to send ritm notification to users . Please help me on this. 

 

 

Thanks, 

Suresh

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

are you saying you don't want email only when the comments are copied from sc_task to RITM but require when normal comments are added?

I believe for copying you must have done GlideRecord update on RITM.

In that you can use setWorkflow(false) to disable notification.

Note: Using setWorkflow(false) will block all BRs from running on update of RITM

Regards
Ankur

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

View solution in original post

8 REPLIES 8

Jaspal Singh
Mega Patron
Mega Patron

Hi Suresh,

Can you share the Business Rule once? I would suggest you adding a keyword that will help differentiate. Share the script so that it can be modified a bit.

Hi Singh,

Business rule:

 

(function executeRule(current, previous /*null when async*/ ) {


    var compare, task_comment2, task_comment, ritm_comment2, ritm_comment;
    task_comment = current.comments.getJournalEntry(1);

    //Remove timestamp and name from additional comment
    var regex = new RegExp('\n');
    var i = task_comment.search(regex);
    if (i > 0) {
        task_comment2 = task_comment.substring(i + 1, task_comment.length);
    }

    var ritm_gr = new GlideRecord('sc_req_item');
    ritm_gr.addQuery('sys_id', current.parent);
    ritm_gr.query();

    if (ritm_gr.next()) {
        ritm_comment = ritm_gr.comments.getJournalEntry(1);

        //Remove timestamp and name from additional comment
        var i1 = ritm_comment.search(regex);
        if (i1 > 0) {
            ritm_comment2 = ritm_comment.substring(i1 + 1, ritm_comment.length);
            
        }
        compare = task_comment2.indexOf(ritm_comment2);

        if (compare == -1) // If No match found
        {
            ritm_gr.comments = "ScTask Comments for " + current.number + " : " + task_comment2.trim();
           
            ritm_gr.update();
        }
    }

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

are you saying you don't want email only when the comments are copied from sc_task to RITM but require when normal comments are added?

I believe for copying you must have done GlideRecord update on RITM.

In that you can use setWorkflow(false) to disable notification.

Note: Using setWorkflow(false) will block all BRs from running on update of RITM

Regards
Ankur

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

Hi Ankur,

By using setWorkflow(false); its working fine , But I have Issue on setWorkflow(false); additional has not coping from sctask to Ritm .

 

Additional Comments are has to copy and email has not to trigger while coping the comments.