I have written a script to stop the deletion of ci, it is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2024 05:48 AM
I have created a before delete business rule in cmdb_ci table and written the below script, but it is not stopping the deletion of ci if ci is linked to incident table, please help.
var gr = new GlideRecord('Task');
gr.addQuery('cmdb_ci', current.sys_id);
gr.query();
if (gr.hasNext()) {
current.setAbortAction(true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2024 10:44 PM - edited 05-04-2024 10:44 PM
Hi @Sujata Lenka ,
If its for only incident table you can gliderecord incident table alone.Also if you are using Task table convert the table name to lower case.
Try this:
var gr = new GlideRecord('incident');
gr.addQuery('cmdb_ci', current.sys_id);
gr.query();
if (gr.next()) {
current.setAbortAction(true);
}
Please mark my answer correct/helpful if it resolved your query.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2024 10:48 PM
Hello @Sujata Lenka
The table name is just task, you have capital T.
Below updated code:
Thank you,
Ali