Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Referencing asset database attribute value in ticket via automation

Joe Hahn September 13, 2023

Hello!

To sum up the context of this ask, I've been working on utilizing an asset database to assist a team in streamlining task creation. One aspect of this that has been a thorn in my side is when creating a task I would like to reference the values of an attribute in the 'Components' field.

The current automation is as such:

  • Trigger: When issue is created
  • IF project = XXX
  • IF issue type = Epic
  • IF Milestone = XXX
    • Then: Create Version - Design & Planning {{customfield_10319.Code Name}}
    • For AQL - objectType = "Top Level" and "Milestone Due" = "02. Design & Planning" and "Issue Type" = Task
      • Then Create a New Task

I've been successful in copying a lot of information from the objects into tickets, I can even get the 'Component' field to fill with the 'Component' attribute of an object. Where the problem lies is; if the 'Component' attribute of the object has more than one value. It fills the task with a string separating the two values with a comma. I need to keep the two or more values distinct.


My main focus has been utilizing the 'additional field' field and attempting to use the information from:

The list of JSON I've attempted and some provide the same result as my problem (values as a string) or don't fill anything at all.

  • { "update": { "Components": [{ "set": [ { "name": "{{#object.Component}}{{value}} {{/}}"} ] }] } }
  • { "update": { "Components": [{ "set": [ { "name": "{{#object.Component}}{{.}}, {{/}}"} ] }] } }
  • { "update": { "Components": [{ "set": [ { "name": "{{#object.Component}}{{.}},{{/}}"} ] }] } }
  • { "update": { "Components": [{ "set": [ { "name": "{{#object.Component}}{{.}}..{{/}}"} ] }] } }
  • { "update": { "Components": [{ "set": [ { "name": "{{#object.ComponentasJsonObjectArray}}{{.}},{{/}}"} ] }] } }
  • { "update": { "Components": [{ "set": [ { "name": "{{#object.Component.asJsonObjectArray}}{{.}},{{/}}"} ] }] } }
  • { "update": { "Components": [{ "set": [ { "name": "{{#object.Component.asJsonObjectArray("value")}}{{.}},{{/}}"} ] }] } }
  • { "update": { "Components": [{ "set": [ { "name": "{{#object.Component.asJsonObjectArray("value")}}{{.}}, {{/}}"} ] }] } }
  • { "update": { "Components": [{ "set": [ { "name": "{{object.Component.asJsonStringArray}}"}] }] } }
  • { "update": { "Components": [{ "set": [ { "name": "{{object.Component.asJsonArray}}"}] }] } }
  • { "update": { "Components": [{ "set": [ { "name": "{{object.Component.asJsonObjectArray("name"}}"}] }] } }

 

1 answer

1 accepted

2 votes
Answer accepted
Joe Hahn September 14, 2023

This was solved by;

  1. after the AQL branch logging the action {{object.Component}}. Which logged the values found in the asset attribute as a string.
  2. creating a variable ( {{comp}} ) using the same smart value in the previous step
  3. adding a log action for {{comp.split(",")}}, logs the string value from step 1 but splitting it at the comma
  4. adding another log action for {{comp.split(",").asJsonObject("name").asJsonArray}} which takes those values making a key:value from the split and turning it in to an array
  5. Finally using the following JSON filled the Component field in the tasks created with the appropriate components found in the asset database.
{
"update": {
"Components": [{
"set": {{comp.split(",").asJsonObject("name").asJsonArray}}
}]
}
}
Joe Hahn September 14, 2023

To be clear the automation works fine without the log actions, they were there so I knew what information was being passed along the way.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events