- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 02:42 PM - edited 04-04-2023 03:18 PM
The below BR is working as expected but it's copying the transcription twice in the work notes of the incident.
We want copy the chat transcript from the interaction record to comments field of the related incident .
We have written an After BR on interaction table
Condition : Transcript is not empty
(function executeRule(current, previous /*null when async*/ ) {
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.comments = current.transcript.toString();
incident.update();
}
}
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 07:17 PM
Hi,
I believe you need to change the when to run condition.
It will make sure to run BR only when interaction is closed. At this moment your Business rule is running every time when the transcript changes.
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 07:51 PM
Hi,
Please try below:
(function executeRule(current, previous /*null when async*/ ) {
var inc = new GlideRecord('interaction_related_record');
inc.addQuery('interaction', current.sys_id);
inc.addQuery('document_table', 'incident');
inc.addQuery('type', 'task');
inc.query();
if (inc.next()) {
var incident = new GlideRecord('incident');
incident.addQuery('sys_id', inc.document_id);
incident.query();
if(incident.next()) {
incident.comments = current.transcript.toString();
incident.update();
}
}
})(current, previous);
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2023 01:44 PM
Unfortunately, it didn't help me yet

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2023 06:46 PM
Hi,
Please make sure you have added proper condition on your BR so that it will not execute multiple times.
(function executeRule(current, previous /*null when async*/ ) {
gs.info('AAAAA - Running my BR'); // add logs to track your br Execution
var inc = new GlideRecord('interaction_related_record');
inc.addQuery('interaction', current.sys_id);
inc.addQuery('document_table', 'incident');
inc.addQuery('type', 'task');
inc.query();
if (inc.next()) {
var incident = new GlideRecord('incident');
incident.addQuery('sys_id', inc.document_id);
incident.query();
if(incident.next()) {
incident.comments = current.transcript.toString();
incident.update();
}
}
})(current, previous);
added log in BR, it should come only once.
you can put more logs to debug your script?
can you please help us understand what is your usecase? when exactly you want to update comments?
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 01:37 PM
I tried with logs and it didn't help. In my case when Interaction is closed completed then I want to update the incident with interaction transcripts
Kindly find the conditions below
Thanks