copy additional comment & worknotes from incident to case .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 10:18 AM
how to copy the additional comments and worknotes from incident to related case record . i have already tried with the BR (before - update )
table- incident
(function executeRule(current, previous /*null when async*/ ) {
var relatedCase1 = new GlideRecord('sn_customerservice_case'); // initialize case table
relatedCase1.addQuery('incident', current.sys_id);
//relatedCase1.addActiveQuery();
relatedCase1.query();
if (relatedCase1.next()); {
relatedCase1.work_notes = current.work_notes;
//relatedCase1.update(); //updates changes
}
})(current, previous);
i have already tried to run the code but it is not working , i am a beginner , i dont know how to done programming properly , help me to find the solution so that i can understand easily.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 10:26 AM
Hi,
It should be a after update BR.
with minute change in the script
var relatedCase1 = new GlideRecord('sn_customerservice_case'); // initialize case table
relatedCase1.addQuery('incident', current.sys_id);
relatedCase1.query();
if (relatedCase1.next()); {
relatedCase1.work_notes = current.work_notes.getJournalEntry(1);
relatedCase1.update(); //updates changes
}
Try.
Thanks,
Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2022 08:35 AM
i have a requirement of copying additional comment and work notes from case to incident and incident to case . i have also tried with taking journalentry but at a time only one BR is working . can you please try it and send me the solution ASAP . i got headache just because of solving this issue . i have already check by doing multiple editing but still not working . can you please test once ,it will be more helpful for me .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-12-2024 12:47 PM
Question, I used this script (thank you for sharing).
We have some incidents that get opened without an associated case, this script is then creating a case. Any thoughts on how to modify to have the script not create the case?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-10-2022 10:44 AM
There is a slight variation in syntax depending on if you are wanting the "last" entry or "all previous" entries:
current.comments.getJournalEntry(-1); //gets all comments on record
current.comments.getJournalEntry(1); //gets just the last comments entry on the record
This is for all journal type fields, so work_notes will behave the same too.