Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

SC task additional comments

GBS
Tera Contributor

Hi, when the SC task state is On Hold the activities are updated with two entries of additional comments and I came to know that is getting copied from RITM, any suggestions on how to restrict it? 

3 REPLIES 3

Anubhav24
Mega Sage

Hi @GBS ,

Can you check if any BR is updating the additional comments from RITM , you can try and do a search on BR under the by building a filter as Script contains "Copied from RITM" or you can do a complete code search from Studio for the phrase "Copied from RITM".

 

Please mark helpful/correct if my response helped you.

GBS
Tera Contributor

Hi @Anubhav24 

I've found a after BR

 

var updateInitiatedBy = updateInitiatedBy || current.sys_id.toString();

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

    if (updateInitiatedBy == current.sys_id.toString()) {

        var grTasks = new GlideRecord("sc_task");
        grTasks.addActiveQuery();
        grTasks.addQuery("request_item", current.sys_id + '');
        grTasks.query();
       
        while (grTasks.next()) {
           
            grTasks.comments.setJournalEntry("Copied from RITM: " + current.comments.getJournalEntry(1));
            grTasks.update();
        }
    }

})(current, previous);

Hi @GBS ,

 

That is where the problem you can try to write a log in this after BR and check if this is the exact reason causing the additional comments to get duplicated , if yes then you need to check your logic both technically and process wise to fix this issue.

 

Please mark helpful/correct if my response helped you.