Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Problem

I would like to link all assigned Checkout assets to a an issue automatically.

Solution

Prerequisites

  • Programing experience

  • Experience using rest API

  • Understanding of Atlassian’s Asset API

  • Experience with Automation for Jira

  • Experience with programing Jira.

Implementation

  1. Set up a Checkout Linked asset field and add to the screen you want to display the assets. Automation for Jira can only update the field if it exist on screen that can be edited.

  2. Create a Jira Automation.

    1. Trigger: This can be one of any number of existing triggers (Issue Created, Updated e.t.c) . We chose to use “Value changes for Reporter”.

    2. Actions: We have a series of 3 actions that make the automation work.

      1. Send a web request to the asset api to retrieve assets assigned to the reporter. We used reporter field because we did not want to create another user field. Therefore, you could just as easily retrieve user id from any other custom field.

        Code Block
        https://<you-instance>.atlassian.net/rest/assetapi/asset/search?assignee={{issue.fields.reporter.accountId}}&limit=100

        This REST call has a default value of 10. Therefore we set the limit to 100. If a user has more than 100 assets, this call will need to be paginated to retrieve all the assets.

      2. The call also requires authorization to work. Therefore we provided it with base 64 encoded basic authentication in the form of

        Code Block
        <Email Address>:API Token

        API token can be generated from your Atlassian id security settings.

      3. Audit log - We used this action to inspect and debug the response from the rest call and format it for the next action. This action can be omitted as it is useful when build the automation.

        Results:

      4. Edit issue fields - This action is used to set the ticket with all the assets retrieved from the Rest API call. Note: Linked asset field requires an array list of asset objects. We used smart values to format the payload as required. You will also need to know the custom field id for linked asset field.

Results

All assets are linked to the ticket automatically.

Table of Contents

Write into our Support Desk with any questions you have.