- 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:42 AM
Hi there,
Have you tried adding debugging? For example, is the while for inc reached? Is the while for incident reached? Is the Business Rule triggered at all? Does current.transcript hold what you would expect?
You do mention "After BR on interaction table". After what exactly? Update? Insert? If insert, is there already a interaction_related_record and incident record at that moment (I would guess not). So is the condition actually oke?
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:46 AM
Yes. The current.transcript holds the value that I'm expecting.
I added an info message in the script and on update of the interaction record, the info message is getting populated with transcript but transcript is not getting copied to the comments field of the incident record
This After BR on interaction table is on Update
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()) {
gs.addInfoMessage(inc.interaction.transcript);
incident.comments = current.transcript;
incident.update();
}
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2021 12:49 AM
gs.addInfoMessage(inc.interaction.transcript);
incident.comments = current.transcript;
Here you are using inc.interaction.transcript and current.transcript. This at least is different? Can you have closer look at this?
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:53 AM
Both inc.interaction.transcript and current.transcript are same - referring to the transcript field on the interaction table