Using Validation Rules with Data Macros to Enforce Workflow and Edit Rules
The Altiris Helpdesk Solution provides a robust library of data macros to simplify the coding and implementation of business rules. The PREVIOUSITEM macro is a great tool to query the previous value of a field prior to updating the database. The PREVIOUSITEM macro combined with Validation Rules are a powerful combination of easy to use features that enforce workflow and business logic in the Helpdesk Solution.
The following example uses the PREVIOUSITEM macro to prevent the editing of an incident that has already been closed. This is useful in environments that have SLA agreements triggered by the closing of an incident and also prevents multiple notifications and reporting of closed incidents.
The rule can easily be imported into Helpdesk Solution and modified to meet your business requirements. Follow the steps below to import and test this rule in your environment.
Step 1: Create the import file
- Copy and paste the following text into Notepad.
<Helpdesk> <ValidationRules> <ValidationRule> <Guid>7eee4bad-6c1c-4c38-95d5-9ac0c8bc60d3</Guid> <Name>Prevent edit of "Closed" incident except for Authorized Workers</Name> <Description>Do not allow worker to edit incident that is "Closed" status.</Description> <Status>active</Status> <Message>Incident WORKITEM(workitem_number) is "Closed" and cannot be modified. Contact your System Administrator for further assistance. Click Cancel (Red 'X') to return.</Message> <LogToNs>yes</LogToNs> <Rank>6</Rank> <ApplyTo>all</ApplyTo> <Criteria> <Criterion field="PREVIOUSITEM(workitem_status_lookup_id)" op="optEqual" value="600" type="uint" /> <Criterion field="" op="" value="1" type="group" /> </Criteria> <Criteria or_together="true" not_result="true"> <Criterion field="workitem_modified_by_worker_id" op="optEqual" value="WORKER ID" type="uint" /> <Criterion field="workitem_modified_by_worker_id" op="optEqual" value="WORKER ID " type="uint" /> <Criterion field="workitem_modified_by_worker_id" op="optEqual" value="WORKER ID " type="uint" /> </Criteria> </ValidationRule> </ValidationRules> </Helpdesk>
- Save the file as techtip.xml.
Step 2: Import the file
- In Helpdesk, click Admin > Import.
- Browse to the techtip.xml file and click the open button.
- Click the import button to add the rule.
Figure 1. Import Admin Data
Step 3: Test the rule
- Create or open an incident that is closed.
- Attempt to change the time, status, or add comments to the incident. The rule should not allow you to modify the incident as seen in the picture below
Figure 2. Unable to edit incident
- Cancel out of the incident edit view.
Step 4: Modify the closed edit privileges
- Click Admin > Validation Rules > List Validation Rules
- View the "Prevent edit of "Closed" incident except for Authorized Workers rule."
Figure 3. List Validation Rules
- Note from the picture below that the sample rule contains 3 workers all equal to "Worker ID" who are authorized to make changes to closed incidents.
Figure 4. View sample rule
- Click pencil icon to modify the validation rule.
- Highlight and choose to edit the first line "Modified by worker is equal to 'Worker ID'."
- If you know the Worker ID number from the Altiris_incidents database worker table, type the Worker ID number and click OK. If you do not know the Worker ID, cancel out of this view.
Figure 5. Edit Validation Rule
- Instead, choose to add new line for "Modified by worker" and select "When the value of the 'Modified by worker:' is equal to 'Administrator'" or whichever worker you prefer to grant rights.
Figure 5. Edit Validation Rule
- Your worker should now have rights to modify any closed incidents and will bypass the validation rule.