Script to update Case work notes from Incident work notes.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2024 03:01 PM
Hello,
I'm trying to have my incident updates magically update the related case, I used the below script and it updates the case notes, however if there is no associated case, it creates a "blank case" that just has the note in it. Any idea what it would take to modify the script and only update if there is an associated/connected case?
Thanks for looking!
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
}
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-11-2024 06:15 PM
Hi @S2_Jerry ,
Try below script:
//Update incidents
var grinc = new GlideRecord("incident");
grinc.addActiveQuery();
grinc.addQuery("rfc", current.sys_id);
grinc.addNotNullQuery("rfc");
grinc.query();
while(grinc.next()){
grinc.close_notes = "YOUR_NOTES_VALUE";
grinc.close_code = "YOUR_CODE_VALUE";
grinc.update();
//update Case table (update table name and field name which holds change request number)
var grcase = new GlideRecord("CASE_TABLE_NAME");
grcase.addActiveQuery();
grcase.addQuery("FIELD_NAME_WHICH_HOLDS_CHANGE_REQUEST", current.sys_id);
grcase.addNotNullQuery("FIELD_NAME_WHICH_HOLDS_CHANGE_REQUEST");
grcase.query();
while(grcase.next()){
grcase.close_notes = "YOUR_NOTES_VALUE";
grcase.close_code = "YOUR_CODE_VALUE";
grcase.update();
}
If I could help you with your Query then, please hit the Thumb Icon and mark it as Correct !!
Thanks & Regards,
Sumanth Meda