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.

Copy Agent Chat Transcript to Related Incident Record

rachelconstanti
Mega Sage

Good morning,

 

I have created the following business rule on the interaction table:
Copy Chat Transcript to Related Incident:

It is an after/update with one condition - State is Closed Complete

This is the script:

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

// Add your code here
var query = "document_table=incident^interaction.number=" + current.number;
var irc = new GlideRecord("interaction_related_record");
irc.addEncodedQuery(query);
irc.query();
if (irc.next()) {

var inc = new GlideRecord("incident");
if (inc.get(irc.task.sys_id)) {
inc.work_notes = current.transcript + "";
inc.update();
}

}

})(current, previous);
 
It is working however the incident work notes are being updated twice.
 
How can I fix that?
 
Thank you,
Rachel
1 ACCEPTED SOLUTION

@Medi C 

Got it figured out 

Removed the condition for State is Closed Completed and 

Added this as a condition Transcript Changes

 

That did the trick

View solution in original post

4 REPLIES 4

Medi C
Giga Sage
Giga Sage

Hello @rachelconstanti,

 

Could you change the condition as this:

State "Changes to" Closed complete 


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.

@Medi C - I changed the condition to State 'Changes to' Closed complete and nothing gets copied.
I have also tried with no condition and it copies twice.

@rachelconstanti 

Could you please tell which table where the business rule is running?
Have you tried using OnBefore business rule instead?


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.

@Medi C 

Got it figured out 

Removed the condition for State is Closed Completed and 

Added this as a condition Transcript Changes

 

That did the trick