using set abort action
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 01:10 AM
if user try to delete the any config item , if that particular item is associated with any other records like incident means , it should abort the delete action.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 01:22 AM
To start with... I would discourage deleting Config items at all. Use install/operational status to maintain your data.
That being said, you will need a delete Business Rule, with script to lookup any relations in the cmdb_rel_ci table. If they exist abort the action.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 01:28 AM
Hi @keerthana
You can write below Delete Business Rule on CMDB table:
var tsk = new GlideRecord('task');
tsk.addQuery('cmdb_ci', current);
tsk.query();
if(tsk.hasNext())
{
current.setAbortAction(true);
}
This will check if any Task based record like Incident, Problem, Change, etc is having current CMDB CI, than it will abort action.
Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 01:28 AM
Hi Keerthana,
If your configs are stored in a table then you can always use Delete business rule for this kind of requirement. Delete BR will only run when a user tries to delete the record from that table.
So, you need to write script in Delete BR that will Glide Record and check Incident table for a specific field where it can find that confing written. If it is found then abort the action else let the user delete the record.
You may have to write multiple Glide Record queries if you want to check multiple tables. I'm writing a sample script for your Delete BR below:
var grInc = new GlideRecord('incident');
grInc.addQuery('Your Config Field which is there on Incident' , current.YOUR_CONFIG_FIELD_ON_CURRENT_TABLE);
grInc.query();
if(grInc.hasNext()){
current.setAbortAction(true);
}
If my answer helps then please mark it Helpful or Correct!
Thanks,
Utpal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-10-2023 07:46 AM
how to check a output