Set Manager using Assets attributes via Automation.
Summary
Sometimes, it is required to retrieve the Manager from the Assets object associated with a user, in this case, the work item reporter. In this Knowledge base, we will see how to set the manager from the Asset object to a work item via automation. In this scenario, the proposed automation will look for the reporter. If there is a match in the Assets object label versus the work item reporter, it will look for the manager Atlassian ID and set it to the ticket; this scenario has a user attribute matching the User label.
Environment
Jira and Jira Service Management Cloud
- Assets.
- Automation.
Automation rule
Some explanation on how the rule works.
The first lookup objects retrieve the user related to the ticket reporter and searches in the People object type. Among this object’s attributes, we can see the Manager attribute. This object attribute also points to the People object type.
So, when the reporter object is found, I use the LookupObjects to point at the Manager attribute object by using “lookupObjects.Manager.” Then, I access the Manager’s Atlassian ID attribute (not the reporter) using the People attribute and use this to populate the approver field in the ticket.
Steps:
To create a new Automation rule, go to project > Project settings > Automation > Create rule
Components:
Step 1. Trigger. Work item Created Trigger. This will execute the rule when an issue is created.
Step 2. Action. Lookup objects, this component retrieves the reporter object using an AQL query correlating the Name attribute versus the reporter work item field:
In my example, the attribute Name has the user’s email address value. Use the below smart value for the People object type. This can be chaned to displayName if needed. See below the AQL query used for this example:
objectType = People AND Name = "{{issue.reporter.emailAddress}}"
or
objectType = People AND Name = "{{issue.reporter.displayName}}"
Step 3. Action. Log action component. This component isn't required, however, it is very helpful to verify the correct objects and values are being retrieved. This has no action on the ticket, I suggest adding it so you know the AQL is getting the correct objects. I'm using the below smart values here:
{{lookupObjects.Manager.Person}}
The above points to the People object type in question > then, references the Manager attribute (in your case, the attribute would be “Manager Name”).
In my example, the Manager attribute points to another People user object attribute (the one I mentioned in the beginning of this response, and shared a screenshot of), from which we will get the Atlassian ID of that object to edit the work item.
Step 4. Action. Edit work item. Here, I'm using the below smart value taken from the Lookup objects component to obtain the “Manager” Atlassian ID:
{{lookupObjects.Manager.Person}}
What if I only have a text attribute with the manager's name?
In this case, we will be using a different approach. Refer to the below automation rule:
Components:
Step 1. Trigger. Work item Created Trigger. This will execute the rule when an issue is created.
Step 2. Action. Lookup objects, similar to the above example, this component retrieves the reporter object using an AQL query correlating the Name attribute versus the reporter's work item field:
Let's suppose the Manager attribute (in my example Manager2 ) has the user’s name as a text value. Use the below smart value for the People object type. See below the AQL query used for this example:
objectType = People AND Name = "{{issue.reporter.displayName}}"
Step 3. Action. Log action component. This component isn't required, however, it is very helpful to verify the correct objects and values are being retrieved. This has no action on the ticket, I suggest adding it so you know the AQL is getting the correct objects. I'm using the below smart values here:
{{lookupObjects.Manager2}}
Step 4. Action. Create variable. This will store the above smart value into a variable.
Step 5. Action. Log action component. Add a log action component to verify the variable's value:
username: {{username}}
Step 6. Action. Send web request. This action component will be used to get based on the variable, the user’s Atlassian ID.
https://{Your_Company_Name}.atlassian.net/rest/api/2/user/search?query={{username.urlEncode}}
HTTP method: GET
Web request body: Empty
Delay execution of subsequent rule actions until we've received a response for this web request: Check this box.
Headers:
| Key | Value |
|---|---|
| Accept | application/JSON |
| Authorization | basic ************ |
Step 7. Action. Log action component. Add a log action component to verify the send web request result value:
{{webResponse.status}} =====> {{webResponse.body.accountId}} =====> {{webResponse.body.get(0).accountId}}
Step 8. Action. Edit work item. Use this component to populate teh work item Approver field using the smart value below:
{{webResponse.body.get(0).accountId}}


