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.

Synchronize catalog task activity and requested item activity

Tadz
Kilo Sage

Hi, how do we synchronize the catalog task activity and requested item activity.

I have successfully synchronize them both using BR for catalog task and BR for Requested Item.

The when to run of my BR's are:

When: before

Update

The problem is, the activity in the catalog task are duplicated.

See the screenshots below:

task_sync1.PNG

task_sync2.PNG

I know that the one causing the duplication is because of the 2 Business rule running. In which the Requested Item BR will be triggered

when the Catalog Task added a work notes.

I also tried adding

if(!current.work_notes.getJournalEntry(-1).split("\n\n")[0].indexOf('Work notes')){

gr.comments = comments;

gr.update();

}

It stops the duplication of the catalog task activity.

But the comments from requested item to catalog task. doesn't work anymore.

Thanks,

Tadz

8 REPLIES 8

K10
Kilo Guru

Hi Tadz,



Remove the current.update() from the before business rule, This should work.


Hi Ketan,



I have no current.update() in my script.


Only gr.update(); since I am using a gliderecord.



Thanks,


Tadz


Ohh I See



Can you paste full BR here ?


function onBefore(current, previous) {


  //This function will be automatically called when this rule is processed.


  var comments = current.comments;


  var sys_id = current.sys_id;



  var gr = new GlideRecord('sc_task');


  gr.addQuery('request_item','=',sys_id);


  gr.query();


  if(gr.next())


  {


  if(!current.comments.getJournalEntry(-1).split("\n\n")[0].indexOf('Work notes')){


  gr.comments = comments;


  gr.update();


  }


  }


}