cmdb_ci and task_ci
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2015 10:36 AM
I have a business rule on task_ci (Affected Cis) which upon deleting the CI from affected cis will throw a message saying you cannot delete if it a primary Ci as well.
But when I try to delete a CI from cmdb_ci, if that ci is a part of an INC, the above business rule is triggered. Why?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-04-2015 01:05 PM
Hi ravali,
It is because before the CI is deleted it tries to delete its relationship. When it comes to 'Affected CI' table and tries to delete related records in it, 'Prevent removal/update of primary CI' BR prevents it from doing so as current.ci_item == current.task.cmdb_ci matches(as CI on the 'Affected CI' record and CI on the parent task i.e. the INC record are same). But as the abort action in the 'Prevent removal/update of primary CI' can only prevent the delete action on the 'Affected CI' table, CI will be deleted.
If you want the CI not to be deleted if there is a related record in 'Affected CI' table then write the below shown Before delete BR on the 'cmdb_ci' table.
When - Before Delete
Order - 50
Script -
function onBefore(current, previous) {
//This function will be automatically called when this rule is processed.
var gr = GlideRecord('task_ci');
gr.addQuery('ci_item',current.sys_id);
gr.query();
if(gr.next()){
gs.addErrorMessage('Cannot delete CI');
current.setAbortAction(true);
}
}
Hope this will give you the desired result
Cheers!!
Thanks,
Tanaji

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-14-2015 05:22 AM
Hi ravali,
If this answers your query, please can you close this by marking correct answer.
Thanks,
Tanaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2015 07:57 AM
Correct answer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2015 10:37 PM
Hi ravali,
Can you please mark it by clicking the 'Mark Correct Answer' below the comments.
Thanks,
Tanaji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2015 08:15 AM
Hi,
I donnot see "Mark COrrect Answer" in here !