- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-15-2017 09:38 PM
Need script to delete a record for specific given sys_id (xyz) in an incident table(for example)?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 03:24 AM
Hi,
You can try this code
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', 'your_sys_id');
gr.query();
gr.next();
gr.deleteRecord();
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 03:24 AM
Hi,
You can try this code
var gr = new GlideRecord('incident');
gr.addQuery('sys_id', 'your_sys_id');
gr.query();
gr.next();
gr.deleteRecord();
Thanks
Please Hit like, Helpful or Correct depending on the impact of the response

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 03:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 05:01 AM
Hi Divya,
Here is an even shorter code snippet:
var gr = new GlideRecord('incident');
gr.get(sys_id_of_record_here);
gr.deleteRecord();
Get() is perfect when you want to retrieve a single record by sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 09:55 PM
Thanks Shiva,
Found your method is the shortest among all.