- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2023 11:22 AM
I have an ask to update 300+ records. While this is doable, the ask includes adding notes to the update, which is always a little trickier. I'm not sure how to dotwalk or access the attached activity list to update it.
var gr = new GlideRecord('incident')
gr.addEncodedQuery('major_incident_state=accepted^hold_reasonIN13,12,14,16^incident_state=6')
gr.query();
while(gr.next()) {
gr.setWorkflow(false);
gr.setValue('work_notes', '"Bulk VP Review RCA cleanup: All VPs were provided a list of RCAs in their orgs, identified by their teams as "Ready for Review". VPs were given two weeks to review, and either request additional review, or the RCAs would be closed. Closing this RCA in accordance with that effort. Any open tasks will be marked Closed/Skipped; the RCA Management task was completed, but for purposes of the update it will reflect Closed/Skipped too."');
gr.setValue('u_origin_of_incident', 'notapp');
gr.setValue('incident_state', '7');
gr.setValue('hold_reason', '9');
gr.update(); }
I tried this version, but of course I discovered I was using outdated dictionary references - work_notes doesn't exist on the incident table.
Does anyone know how to add notes via a background script? I'm also trying to close any related incident tasks, which shouldn't be as difficult, I think, but this was the big one I wanted to knock out first.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2023 11:35 AM - edited 05-14-2023 11:38 AM
Hi @Venjamin
setValue will not work on journal type fields,use gr['work_notes'] instead, so, your script should be:
var gr = new GlideRecord('incident')
gr.addEncodedQuery('major_incident_state=accepted^hold_reasonIN13,12,14,16^incident_state=6');
gr.query();
while(gr.next()) {
gr.setWorkflow(false);
gr['work_notes'] = 'Bulk VP Review RCA cleanup: All VPs were provided a list of RCAs in their orgs, identified by their teams as "Ready for Review". VPs were given two weeks to review, and either request additional review, or the RCAs would be closed. Closing this RCA in accordance with that effort. Any open tasks will be marked Closed/Skipped; the RCA Management task was completed, but for purposes of the update it will reflect Closed/Skipped too.';
gr.setValue('u_origin_of_incident', 'notapp');
gr.setValue('incident_state', '7');
gr.setValue('hold_reason', '9');
gr.update();
}
If my answer has helped with your question, please mark it as correct and helpful
Thanks,
Karan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2023 12:40 PM
@Venjamin - that's because you've used gr.setWorkflow(false), worknotes are stored in 'sys_journal_field' table and they are inserted there via some OOB business rule.
If you remove 'gr.setWorkflow(false)' from the script, work notes would show up.
If my answer has helped with your question, please mark it as correct and helpful
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2023 11:35 AM - edited 05-14-2023 11:38 AM
Hi @Venjamin
setValue will not work on journal type fields,use gr['work_notes'] instead, so, your script should be:
var gr = new GlideRecord('incident')
gr.addEncodedQuery('major_incident_state=accepted^hold_reasonIN13,12,14,16^incident_state=6');
gr.query();
while(gr.next()) {
gr.setWorkflow(false);
gr['work_notes'] = 'Bulk VP Review RCA cleanup: All VPs were provided a list of RCAs in their orgs, identified by their teams as "Ready for Review". VPs were given two weeks to review, and either request additional review, or the RCAs would be closed. Closing this RCA in accordance with that effort. Any open tasks will be marked Closed/Skipped; the RCA Management task was completed, but for purposes of the update it will reflect Closed/Skipped too.';
gr.setValue('u_origin_of_incident', 'notapp');
gr.setValue('incident_state', '7');
gr.setValue('hold_reason', '9');
gr.update();
}
If my answer has helped with your question, please mark it as correct and helpful
Thanks,
Karan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2023 11:59 AM
Thank you for your info. I will say, though it seemed to insert into the journal entry, it's not showing up in the activities / notes section on the individual incident it should be attached to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 05:39 AM
Hi @Karan Chhabra6 ,
Same like i wanted to update the work notes of requested item with gr.setWorkFlow(false) in the script. But the workflow comments are not updating
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2023 12:40 PM
@Venjamin - that's because you've used gr.setWorkflow(false), worknotes are stored in 'sys_journal_field' table and they are inserted there via some OOB business rule.
If you remove 'gr.setWorkflow(false)' from the script, work notes would show up.
If my answer has helped with your question, please mark it as correct and helpful
Thanks!