I have been wanting to make a task that would force a notify rule to be enabled on a helpdesk incident. I wrote a set of queries and found what I needed to update. Once I created the taskI stumbled across an issue. It has to do with Altiris HD solution processing the a sql statement before I even run the task.
My task looks a bit like this. It sets the workitem to have a rule ‘293’ enabled on it.
Set: HDQUERY[[select workitem_number from dbo.workitem_wuci_join where workitem_wuci_join.wuci_id = '293' and workitem_wuci_join.workitem_number = WORKITEM(workitem_number)]]
The above is just filler really. The code that matters is below. Since Altiris doesn’t provide a way to just update/insert a sql value you hide the sql statement in an HDQUERY macro.
To: HDQUERY[[select NULL insert into dbo.workitem_wuci_join (workitem_number, wuci_id) values (WORKITEM(workitem_number), 293)]]
However each time the rule is displayed it actually updates the database. I think Altiris is processing the to: to get a value which is running the insert.
I also found that the select NULL was needed to supress errors when running the rule. When running this rule I found that it adds a duplicate entry for the 293 rule. This breaks the incident. To fix this use a sql delete in the workitem_wuci_join table of the altiris_incidents database.
delete * where workitem_number = '' and wuci_id = '293'
This will delete all rows (likely only 2) with the rule id and the incident number. Then you can simply edit the incident in helpdesk console and add the proper notify rules.