Update comments in incident by using background script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 04:58 AM
Hi,
I wrote a background script to update the comments in incident table But didn't update the comments. Please help
Script:
var gr = new GlideRecord('incident');
gr.get('88041f451b080d1039068550604bcb2d');
gr.comments = 'As requested, closed the incident record';
//gr.autoSysFields(false);
//gr.setWorkflow(false);
gr.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 05:16 AM - edited 08-29-2024 05:19 AM
You should always use get in an if condition. This way you can confirm that the record was retrieved.
var gr = new GlideRecord('incident');
if (gr.get('88041f451b080d1039068550604bcb2d')) {
gs.print('Incident record found ' + gr.number);
gr.comments = 'As requested, closed the incident record';
//gr.autoSysFields(false);
//gr.setWorkflow(false);
gr.update();
} else {
gs.print('Incident record not found.);
}
Other than ensuring you are using a valid incident sys_id, a similar Fix Script works fine in my PDI.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 05:29 AM
I wrote script and it is not updating the record.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 05:46 AM
So CTRL0020372 is a record on the incident table which you are showing in the screenshot? Do you have permission to add a comment to this record manually? I'm not seeing a Post button.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2024 05:52 AM
No i don't have permission to add manually. what should i have to do?