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
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.
Create a Jira Automation.
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”.
Image ModifiedActions: We have a series of 3 actions that make the automation work.
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.
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.
Image ModifiedAudit 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.
Image ModifiedResults:
Image ModifiedEdit 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.
Image Modified
Results
All assets are linked to the ticket automatically.
Image ModifiedTable of Contents |
---|