I have requirement to copy the additional comments and work notes from RITM to Request and Case form
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2023 10:40 PM
I have requirement to copy the additional comments and work notes from RITM to Request and Case form. When an external user creates an request one case get's created and under that Request > RITM.
I was trying to copy the additional comments and work notes (activities) from RITM record to Request and Case. My code is copying the activities properly from the RITM to Request but not on Case.
The additional comments is getting copied as work notes on Case. and work notes itself aren't getting copied,
Below is my code:
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sc_request');
gr.addQuery('number', current.request.number);
gr.query();
if (gr.next()) {
gr.work_notes = current.work_notes.getJournalEntry(1);
gr.comments = current.comments.getJournalEntry(1);
gr.update();
var gr1 = new GlideRecord('sn_customerservice_case');
gr1.addQuery('number', gr.parent.number);
gr1.query();
if (gr1.next) {
gs.addInfoMessage('Hello snehal inside case if');
gr1.work_notes = current.work_notes.getJournalEntry(1);
gr1.comments = comments;//current.comments.getJournalEntry(1);
gr1.comments_and_work_notes = current.comments_and_work_notes;
gr1.update();
}
}
})(current, previous);
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2023 10:50 PM
Hi @Snehal12
try this
(function executeRule(current, previous /*null when async*/ ) {
var gr = new GlideRecord('sc_request');
gr.addQuery('number', current.request.number);
gr.query();
if (gr.next()) {
gr.work_notes = current.work_notes.getJournalEntry(1);
gr.comments = current.comments.getJournalEntry(1);
gr.update();
var gr1 = new GlideRecord('sn_customerservice_case');
gr1.addQuery('number', gr.parent.number);
gr1.query();
if (gr1.next()) {
gs.addInfoMessage('Hello snehal inside case if');
gr1.work_notes = current.work_notes.getJournalEntry(1);
gr1.comments = current.comments.getJournalEntry(1);
gr1.update();
}
}
})(current, previous);
Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP