We are facing issue on copying transcript from interaction to the associated incidents

rajeshKongamudi
Tera Contributor

Hi Community,

 

We are facing issue on copying transcript from interaction to the associated incidents. 

when end user started the chat and virtual agent start finding the solution and when he is creating incident when the interaction is in progress the transcript is copied to the incident because it is already associated by default, but when interaction is closed complete and after incident is created then interaction got closed complete here we need to copy the transcript to all the associated incidents when we are manually associating the incidents, can anyone please help us on this. Thanks in advance.
 
//This is the business rule we are using//
(function execute Rule(current, previous /*null when async*/) {
// Add your code here
var inc = new GlideRecord('interaction_related_record');
inc.addQuery('interaction', current.sys_id);
inc.addQuery('document_table', 'incident');
inc.addQuery('type', 'task');
inc.query();
 
while (inc.next()) {
var incident = new GlideRecord('incident');
incident.addQuery('sys_id', inc.document_id);
incident.query();
while (incident.next()) {
incident.work_notes = current.transcript.toString();
//incident.comments = current.transcript.toString();
incident.update();
 
}
}
})(current, previous);
//

 

2 REPLIES 2

Danish Bhairag2
Tera Sage
Tera Sage

Hi @rajeshKongamudi ,

 

Can u try the below code.It should work.

 

var inc = new GlideRecord('interaction_related_record');

inc.addQuery('interaction', current.sys_id);

inc.addQuery('document_table', 'incident');

inc.addQuery('type', 'task');

inc.query();

 

while (inc.next()) {

var incident = new GlideRecord('incident');

incident.addQuery('sys_id', inc.task);

incident.query();

if(incident.next()) {

incident.work_notes = current.transcript.toString();

//incident.comments = current.transcript.toString();

incident.update();

 

}

}

 

Thanks,

Danish

 

Hi @Danish Bhairag2 

 

Thanks for the reply, actually the previous code is also working the problem here is the code is not working if the incident is created when interaction is InProgress but when the interaction is closed complete and then we are trying to create incident and associating to the closed interaction then is not copying the comments. Please help me with this req. here is the run condition we are giving. and which ever code you have provided is working same as above one.

rajeshKongamudi_0-1697967668578.png