- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2023 01:16 AM
Hi All,
-> I have a requirement to update the affected ci related list based on update of "Configuration item" on the change form.
-> I have written before update BR to remove old ci entries based on ci update. but when updating the record it populate the OOTB info message "A task's primary CI cannot be removed from Affected CIs - change or remove the CI from the task form instead"
-> Even I am not trying to delete primary ci which we selected on the change form. But still I am getting this message. I am not sure where I did mistake. Can anyone please help.
Before Update BR:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2023 04:08 AM
Have you confirmed in the ci_list log that the array does not contain a task_ci record that contains the previous.cmdb_ci or the current.cmdb_ci? A more straightforward and efficient way to handle the removePreviousCI function would be to use the array in the addQuery like this so that you are only deleting records once:
var rec = new GlideRecord('task_ci');
rec.addQuery('task', current.sys_id);
rec.addQuery('sys_id', 'IN', ci_list.join(','));
rec.query();
while (rec.next()) {
rec.deleteRecord();
}
If you are certain you are not removing an affected CI record that is the primary cmdb_ci on the Change record then you can add this line before this while loop that deletes records so that no other Business Rules will run
rec.setWorkflow(false);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-12-2023 04:08 AM
Have you confirmed in the ci_list log that the array does not contain a task_ci record that contains the previous.cmdb_ci or the current.cmdb_ci? A more straightforward and efficient way to handle the removePreviousCI function would be to use the array in the addQuery like this so that you are only deleting records once:
var rec = new GlideRecord('task_ci');
rec.addQuery('task', current.sys_id);
rec.addQuery('sys_id', 'IN', ci_list.join(','));
rec.query();
while (rec.next()) {
rec.deleteRecord();
}
If you are certain you are not removing an affected CI record that is the primary cmdb_ci on the Change record then you can add this line before this while loop that deletes records so that no other Business Rules will run
rec.setWorkflow(false);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2023 08:42 AM
Hi @Brad Bowman ,
It is working.. Thank You!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-18-2023 09:16 AM
You are welcome!
