We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

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

Hello @rachelconstanti,

 

Could you change the condition as this:

State "Changes to" Closed complete 


Thanks & Best regards,
Medi

@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?


Thanks & Best regards,
Medi

@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