anyone knows about business rules 'Prevent removal/update of primary CI'?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2011 11:23 AM
We implemented change by having the information fill on change request, and that information get copy to change task, and approvals happen on change task. So what my business rules need to do is, it needs to recreate the task whenever there's an update on the change request.
I have a business rules that run against change request table, that will delete a task when a change request was updated. It works ok with changes on other fields but when changes the CI fields and update. Message show up as "You cannot remove this CI since it is the primary CI on the associated task.Please change or remove the CI from the task form". This is coming from 'Prevent removal/update of primary CI' business rule.
I'm not sure how i could get around this rule to accomodate our requirement. What i want to do is to delete existing task, workflow kicks off, new task get created. But what happen now is, change request updated, task delete, no new task created, message show up "You cannot remove this CI since it is the primary CI on the associated task.Please change or remove the CI from the task form". wouldn't deleting a task will delete the record in task_ci as well?
when:after
update: true
Condition: current.changes() && current.u_task_approval_requested = false
cancelWorkflows( ); function cancelWorkflows( ) { var wf = new Workflow(); current.work_notes = "Change request was updated before submitted for approval, workflow restarting."; current.update(); //new WorkflowApprovalUtils().cancelAll(current, comment); //wf.cancelContext(flows); wf.restartWorkflow(current); var tsk = new GlideRecord('change_task'); tsk.addQuery('change_request', current.sys_id); tsk.addQuery('Active',true); tsk.addQuery('state',-5); tsk.query(); while(tsk.next()) { //tsk.work_notes = 'Change request workflow reset.'; //tsk.state = 4; //tsk.update(); tsk.deleteRecord(); }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2011 02:14 PM
This message will only show up if your script attempts to delete the affected ci on the task. Its purpose is to ensure that the CI in the 'Configuration item' field is always represented in the 'Affected CIs' related list. This script did have a bug in it at one point that might be causing you issues. You might try replacing the code there with this...
//Check the parent task to make sure that the CI is not listed there
if(current.ci_item && current.operation() == 'delete' && current.ci_item == current.task.cmdb_ci){
//Disallow removal
gs.addInfoMessage('You cannot remove this CI since it is the primary CI on the associated task.</br>Please change or remove the CI from the task form.');
current.setAbortAction(true);
}
if(current.ci_item.changes() && current.operation() == 'update' && previous.ci_item == current.task.cmdb_ci){
//Disallow modification
gs.addInfoMessage('You cannot change this CI since it is the primary CI on the associated task.</br>Please change or remove the CI from the task form.');
current.setAbortAction(true);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2011 09:16 PM
Thanks for your reply mark. This business rule is the same as what we have in our instance.
This rule trigger whenever i tried to change the cmdb_ci field on change request form and update. Why wouldn't it allow me to delete the change task? There isn't any associated task with the primary CI. Is there anything that i missed?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-19-2011 09:45 PM
I'm not sure exactly what's going on. I would recommend manually deleting tasks until you find the one that's causing the error. I would also recommend that you do not delete tasks in the system, but use the workflow rollback or set the tasks to closed skipped instead. You've also got an issue in your query that's going to cause you other problems if you're not careful...
tsk.addQuery('Active',true);
'Active' should be 'active'