Update the Badge Configuration Item with Link to the User
In this exercise you will learn how to update the status and the location of a Configuration Item and link the Configuration Item to a user.
When a parking access badge CI is selected and linked to the task ‘Reservation of Parking Space – Prepare a Badge’, you want to set the status of this CI to ‘In Production’, empty the location field (Widget Facilities Management sets the location to ‘Reception desk’ when the badges are available in stock) and link the CI to the user who requested the reservation of the parking space.
Create a new Task Template Automation Rule on the ‘Reservation of Parking Space – Prepare a Badge’ task with the name ‘Update the Badge Configuration Item with Link to User’. You know how to write the statements for the following:
- Execute this action when the task is set to status ‘Completed’
- Retrieve the Request and the Requested For user
This automation rule should only be executed when a CI is linked to the task. So, you need to add:
badge_not_found |
cis[first] = nil |
And for the rules’ condition:
condition |
is_completed and not badge_not_found |
You need to retrieve the badge CI with the following statement:
badge |
cis[first] |
That’s all you need for the expressions. Now you can define the actions. Setting the status of the CI to ‘In Production’ and emptying the location field is easy:
Update | badge |
Set | status = in_production |
Update | badge |
Set | location = nil |
Finally, you need to link the CI to the user. A CI can be linked to multiple users, so users is a collection. From a previous exercise you know how to add a record to a collection:
Update | badge |
Add | requester to users |
Your automation rule should look like this: