Automation to update External asset platform field in a Jira issue based on a user picker field

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

This article describes how to set a value for an External asset platform custom field in a Jira issue using automation based on the assignee.

The External Asset platform field is not the same as JSM Assets objects field. This field is used by third-party asset management tools integrated with your Jira site whereas Assets Objects field is used by the built-in JSM Assets features available in Premium and Enterprise plan. You can refer to this documentation to know more about the External Assets platform.

Environment

Jira cloud

Solution

Let's say, you want to automatically populate the External assets field called Laptops with the asset that belongs to the user set in user-picker custom field called Employee. Every asset in External Assets contains a parameter called assignee that contains accountID of the Jira user set to whom the asset belongs to. We will be using the GET Search assets API to search for the asset based on the user and fetch the appKey and originId which will be used to set the value for the asset field in format appKey/originId. For example: If appKey is com.myasset.app and originId is 1, then value will be com.myasset.app/1.

  1. Create an automation rule and set a trigger e.g. Issue Created. You can refer Jira automation triggers for information on automation triggers.
  2. Add a Send web request action to send the GET Search assets API request and  enable the option Delay execution of subsequent rule actions until we've received a response for this web request. The action will be configured as below:
    • Web Request URL: https://<your-domain>.atlassian.net/rest/assetapi/asset/search?assignee={{issue.Employee.accountId}}
    • Headers:
      Accept: application/json
      Content-Type: application/json
      Authorization: make sure that you add the keyword Basic followed by the base64 of your emailaddress:APItoken.So if the base64 of the emailaddress:APItoken is AB12XY45 then to the Authorization header, add the value Basic AB12XY45(Refer to Supply basic auth headers)
    • HTTP method: GET
    • Web request body: Empty
  3. Use Log Action to confirm the values obtained for appKey and originId:
    1. appKey: {{webhookResponse.body.values.origin.appKey}}
    2. originId: {{webhookResponse.body.values.origin.originId}}
      The smart value {{webhookResponse}} is used to fetch the values returned by Send Web Request action
  4. Add the Edit issue and under More options, specify the below in the Additional fields  section:

    {
        "fields":
        {
            "Laptops":
            [
                {
                    "value": "{{webhookResponse.body.values.origin.appKey}}/{{webhookResponse.body.values.origin.originId}}"
                }
            ]
        }
    }


Please reach out to support if you have any questions. 



Last modified on Jan 8, 2024

Was this helpful?

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