How to auto-populate approvers from Asset objects attributes using automation in Assets

Still need help?

The Atlassian Community is here for you.

Ask the community

 

Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.

   

Summary

Refer to the below examples to automatically fetch the approvers from Asset objects.

For more examples refer to the article: How to update object attribute values using automation in JSM Assets

Environment

Only applicable to Automation for Jira and JSM Assets on Cloud environments.

(info) This solution cannot be implemented in a Server/Data Center environment, since the Lookup objects action is not available for this platform. We do have an open feature request to add this feature to Data Center tracked in https://jira.atlassian.com/browse/JIRAAUTOSERVER-947.

Solution

Example1: Copy a single user attribute of an object to a Jira user field
Let's assume we have an object type Employee with Manager information as a reference to itself. When one of the Employees reports an issue, you want their Manager to be added as an Approver:


  1. Trigger an automation rule when an issue is created
  2. Add a lookup object action to find the Manager of the reporter. Below AQL returns the Employee object for the reporter

    objecttype = "Employee" and "Jira user" = {{reporter.accountId}}
  3. Add an Edit action to update the Approvers field with the below smart value:

    {{lookupObjects.Manager.Jira user.accountId}}



Example2: Copy a single user attribute of an object to a Jira Asset object custom field
Let's assume the same example as above, we have an object type Employee with Manager information as a reference to itself. When one of the Employees reports an issue, you want their Manager object to be added to an Asset object custom field "Manager"

  1. Trigger an automation rule when an issue is created
  2. Add an Edit issue action to update the Manager Asset object custom field:
    Below AQL returns the Manager object of Employee mentioned as Jira User:

So add the below AQL in the Edit action along with the smart value of the reporter. Because this is an Asset object custom field, adding an AQL directly will help. There is no need to use the lookupobject action in this case:

objecttype = "Employee" and object HAVING inboundReferences("Jira user" = {{reporter.accountId}}) 



Example3: Copy multiple users from multiple objects to a Jira multi-user field
Let's assume we have an object type System with a user attribute Owners with cardinality set to unlimited. We can fetch these owners on Jira issues as approvers. The system objects on which change is scheduled are already linked to the issue via an Asset object custom field System object. You can fetch the Owners of the linked object to the Approvers field:

  1. Create an automation rule that triggers when an issue is created.
  2. Add an Edit action to update Approvers with the below value that fetches the Owners of the linked objects:

    {
        "fields": {
            "Approvers": {{System object.Owners.flatten.asJsonObjectArray("id")}}
        }
    } 


Example4: Copy multiple users from multiple objects to a Jira multi-user field when there are no linked objects 
In some scenarios, objects from where you want to fetch the Approver information are not linked to the issue. In that case, you can add a lookupobject action first to fetch the objects you are interested in.
Let's assume you have an object type Service desk teams with the team member information stored in Assets. When an issue is created let's say a text custom field or a select list contains the team name that is going to approve the request. 

  1. Create an automation rule that triggers when an issue is created.
  2. Add a lookupobject action that returns the objects with the team name mentioned on the issue in the text custom field textCF Or select list custom field selectlistCF

    objecttype = "Service desk teams" AND "Name" = "{{textCF}}" ORobjecttype = "Service desk teams" AND "Name" = "{{selectlistCF.value}}"
  3. Add an Edit action to update Approvers with the below value that fetches the Team members of the objects returned by the lookup action:

    {
        "fields": {
            "Approvers": {{lookupObjects.Members.flatten.asJsonObjectArray("id")}}
        }
    } 





Last modified on Mar 21, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.