Copy Case Additional Comments into Incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2023 05:58 PM
Hi, I'm trying to copy additional comments from Case (Portal) into Incident and created before update business rule, this seems not to work. Can someone assist?
(function executeRule(current, previous /*null when async*/ ) {
if (!gs.nil(current.comments)) {
var grInc = new GlideRecord('incident');
if (grInc.get('sys_id', current.incident.sys_id)) {
grInc.comments = 'Work notes update on incident ' + current.number + ': ' + current.comments;
grInc.update();
}
}
})(current, previous);
Thanks,
SK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2023 06:16 PM
Hi @Sunil_th ,
Try with below script.
(function executeRule(current, previous /*null when async*/ ) {
if (!gs.nil(current.comments)) {
var grInc = new GlideRecord('incident');
if (grInc.get('parent', current.sys_id)) {
grInc.comments = 'Work notes update on incident ' + current.number + ': ' + current.comments;
grInc.update();
}
}
})(current, previous);
Thanks,
Anvesh
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 06:27 AM
Thanks for the script, that didn't work. Is it some other condition in the business rule that's causing this?
Thanks,
Sunil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 07:13 AM
Hi @Sunil_th ,
Change the BR to After - Update and a condition like below, and use the script provided below.
(function executeRule(current, previous /*null when async*/ ) {
var inc = new GlideRecord('incident');
inc.addQuery('parent', current.sys_id);
inc.query();
while (inc.next()) {
var comment = current.comments.getJournalEntry(1);
inc.comments = comment.trim();
inc.update();
}
})(current, previous);
Thanks,
Anvesh
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-05-2023 11:42 AM
Hi @Sunil_th ,
Have you tried this script, let me know if it helped you to solve the issue.
Thanks,
Anvesh
Anvesh