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.

Question About field Additional Comments

ItayB
Tera Contributor

Hello Guys, 

This is my mission: 

 

"When the customer (requested for) - writes a comment (Additional comment) on the request: the comment will be copied to all open tasks."

 

I tried to use Business Rule but there is what happened:

* The Comment will not seen in the tasks of the RITM. 

* The Comment write twice in the SOW view and in the RITM View.

 

ItayB_0-1751466544307.png

ItayB_1-1751466577648.png

 

 

6 REPLIES 6

Hi @ItayB ,

1. Either you can add setWorkflow(false) on the BR script as below 

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

    var taskGr = new GlideRecord('sc_task');
    taskGr.addEncodedQuery('request_item=' + current.getValue('sys_id') + '^stateIN1,2');
    taskGr.query();

    while (taskGr.next()) {
        taskGr.comments = current.comments;
		taskGr.setWorkflow(false);
        taskGr.update();
    }

})(current, previous);

 

or 

 

2. check if there is any BR on sc_task table which contains current.update() statement in script

use script tracer to find out which script is responsible for duplicate comments

 

or a flow which is duplicating the comments check if there any flows triggered and duplicating the comments

 

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

 

 

Mohammad Danis3
Tera Expert

Hi @ItayB ,
Please use setWorkflowFalse() function.

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

    var taskGr = new GlideRecord('sc_task');
    taskGr.addEncodedQuery('request_item=' + current.getValue('sys_id') + '^stateIN1,2');
    taskGr.query();

    while (taskGr.next()) {
        taskGr.comments = current.comments;
		taskGr.setWorkflow(false);
        taskGr.update();
    }

})(current, previous);

 If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards,
Mohammad Danish