Workaround for using smart value functions with Assets data in Automations
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
The Automation service can be used to retrieve and handle Jira Service Management Assets data in a number of ways, however due to certain bugs impacting data processing for the returned Assets data, Jira smart value functions such as text, list and math functions do not work as expected. The primary workaround at this time is to use the Create variable action in Automations to set the value of the returned Assets data. Variables currently return data in text format, which allows various smart value functions to be used on the data stored in the variable.
This document will list the associated bugs and provides examples and workarounds for the associated functions.
Associated bugs
The following bugs have been identified to be impacting how Automation functions handle Assets data returned through branches using AQL, the Lookup Objects action or accessing Objects within Assets custom fields on an issue:
JSDCLOUD-12734 - Getting issue details... STATUS
JSDCLOUD-12733 - Getting issue details... STATUS
JSDCLOUD-12831 - Getting issue details... STATUS
JSDCLOUD-12834 - Getting issue details... STATUS
Solution
In all four scenarios, the workaround to allow the attributes to be used by the functions listed above is to create a variable and to set the value of the variable to the data returned from Assets. An example of this would be using the Lookup Objects action to query Assets and using the split text function on the data returned as part of a JSON payload. This is because the .split(",") text function converts text data into list data, allowing the various functions to operate on the data.
- In this example, we are accessing an Object with a Select attribute type called Components holding the values ABC and XYZ:
- For testing purposes the following trigger and AQL configuration will be used with the Lookup Objects action:
- Trigger: Manual trigger from issue
- Schema: DEMO AQL:
Key = DEMO-123
- Using the Create variable action the result of the Lookup Objects action can be set as the. The following data is used with the variable:
- Variable name: componentObject
- Smart value:
{{lookupObjects.Components}}
As this example is for demonstration purposes, the result is captured in a log action, however the payload below can be used to edit an issue field via the advanced field editor in the Edit issue action. In this case the split function can be used to create a list of values that can be converted into a valid JSON payload using JSON functions:
{{componentObject.split(",").asJsonObject("name").asJsonArray}}
The result of the above log action is shown in the screenshot below:
List functions
Note: When using list functions, the variable will need to have the split function applied to it similar to the example above in order to convert the variable's text format to a list. Using the same data from the above example, the following smart value will return the size of the list after the split, in this case 2:
{{componentObject.split(",").size}}