- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2021 12:38 AM
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;
incident.update();
}
}
})(current, previous);
This is not working.
Please help
Thanks
Solved! Go to Solution.
- Labels:
-
Agent Workspace

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2021 01:02 AM
Just tried your exact code on my PDI. Only added .toString()
incident.comments = current.transcript.toString();
Works fine with .toString(), without it doesn't work.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2021 12:55 AM
Yeah sure, that's what I theoretically would expect. Though you are not using current.transcript in the info, so did you verify that? You verified inc.interaction.transcript.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2021 12:57 AM
Added current.transcript in the info message and verified it is working as expected
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()) {
gs.addInfoMessage(current.transcript);
incident.comments = current.transcript;
incident.update();
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2021 01:02 AM
Just tried your exact code on my PDI. Only added .toString()
incident.comments = current.transcript.toString();
Works fine with .toString(), without it doesn't work.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020, 2021 ServiceNow Community MVP
2020, 2021 ServiceNow Developer MVP
---
LinkedIn
Community article, blog, video list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-28-2022 09:57 AM
Hi Mark,
I implemented this script and it works. I have two questions though.
1. It's writing the same transcript twice in the incident activity section. I inserted a gs.log line after the incident.update(); line just to make sure it was only this BR that was updating the incident twice and there were two identical entries in the log, so it is this BR. Any idea why it's writing the transcript twice?
2. It's not writing the transcript immediately after the incident is created and only writes it after the user completes the chat experience survey by selecting Good, Neutral or Bad. I can see users skipping this survey and just exiting the chat conversation once they see the incident has been created. I would like to capture the chat transcript as soon as the incident is created and not wait until the survey is completed. Is this possible?
Thanks,
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2023 02:40 PM
The above script in copying the transcript in the activity of the incident twice.