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.

Additional comments synchronization between REQ, RITM, SCTASK

John241
Tera Expert

Hi !

I would like to synchronize additional comments between REQ, RITM, SCTASK. 

I have try this, but it work just in one direction : https://community.servicenow.com/community?id=community_question&sys_id=ff2acf69db5cdbc01dcaf3231f9619e5&view_source=searchResult

Have you some ideas?? 

Thank you. 

5 REPLIES 5

Allen Andreas
Tera Patron

Hi,

I had a whole reply typed out to this but I guess it never got sent.

So that would be the thread I was going to give you as a good example, but as you've said, it goes in one direction.

What I would recommend is still follow that thread, for that table, but also tweak it and create it for the other tables as well. So a variation three times, three BRs total.

THEN make a condition that if the additional comments = 'last comment' then don't run again, else you run the risk of a loop going over and over.

So while you have three BRs, with a slight gliderecord variation, you have the condition in there listed to stop it from running over and over. That's really the only way to get it to work with ANY three...

Since you're saying it only works one way...meaning you HAVE to initially comment 'here' for it to go to y, z....

You want it to work that if you went to z, it still syncs to y and x...and if you went to y....it goes to x and z, right?

So if you follow my advice, it would work.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Thank you for your reply.

"You want it to work that if you went to z, it still syncs to y and x...and if you went to y....it goes to x and z, right?" That's right

Have you an example of the condition to prevent looping? 

so add this to the top:

var comm = current.comments.getJournalEntry(1);

Then in the BR script have this 'if' statement before it can activate, something like:

if (variableofnewcomment != comm) {

DO ALL THIS STUFF

}

You'd need to have the brand new comment as a variable defined at the top as well that you can reference in the above if statement.

So it'll check the new comment being added to see if it matches the last comment that was added to this table (again, you'll need to do this 3 times), and if it does, it won't do anything.

This needs to be a Before BR on Update.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

sachin_namjoshi
Kilo Patron
Kilo Patron

Create an after business rule on sc_task table

 

When: after insert and update

 

Conditions: Additional comments changes
Script:

 

var gr= new GlideRecord("sc_req_item");

 

gr.get(current.getValue("request_item"));

 

gr.<field name on request item>=current.comments.getJournalEntry(1);

 

gr.update();

 

you can reuse same code for updating additional comments on sc_request table as well. just update table name and correct column name for additional comments.

 

Regards,

Sachin