Create a custom list object to loop through - Jira Automation

Talha Shah October 24, 2022

I am trying to create a list variable that I create myself and is not pulled from any fields in Jira. The idea is to be able to iterate through this list in a for loop in Jira Automation to help create multiple epics with different epic names. I know this is incorrect syntax but this is what I am trying to go for:

 

customList =

{{#list}}{{This is my epic name 1}}{{This is my epic name 2}}...{{This is my epic name n}}{{/}}

 

and then in a for loop be able to access each element in the costomList object to efficiently create many epics.

 

The error I get when I try to create a smart value like I did above is: "The provided smart value was unable to be resolved to an object."

1 answer

1 accepted

11 votes
Answer accepted
Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 24, 2022

Hi @Talha Shah and welcome to the community,

You can do that by doing the following:

  • Trigger: Whatever you want. Me, for testing purposes I've choses "issue updated", but you can choose whatever you want
  • Action: Create Variable -> This will store your "list". And I'm saying "list" because this variable is a text and not a list. So put whatever name you (e.g. myList) want and as a value write:
    valueA,ValueB,ValueC
  • Advanced Branching:
    • Smart Value: {{myList.split(",")}}
    • Variable Name: MyEpicSummary
  • Action (inside branching): Create Epic:
    • Summary: On summary place the {{MyEpicSummary}} new variable

 

Your rule should look like this:

Overview

createRule001.png

 

Create List Variable

createRule002.png

Advanced Branching

createRule003.png

Create Task (epic in your case)

 

createRule004.png

 

Audit Log & Results

createRule005.png

createRule007.png

createRule006.png

Let me know if that worked! :)

Talha Shah October 24, 2022

Hey Alex,

Thanks for such a thorough response, it has been really easy to follow and unbelievably useful. Just one question though, when I try to create the myList csv variable, I'm not able to use any spaces within each "string". For example, for your myList smart value youve used "valueA,valueB,valueC" and then split at the commas. Would it be possible to somehow have the smart value "value A,value B,value C" (note the space between 'value' and 'A')? Looking forward to hearing back.

Alex Koxaras _Relational_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 24, 2022

@Talha Shah unfortunately, no. You can't use any spaces.

However, as a workaround, what you could do is to write your summaries as e.g.:

this_is_my_summary,this_is_another_summary,yet_another_summary

And what you will do is to replace the "_" with a space using the .replace function on {{myEpicSummary}}:

{{myEpicSummary.replace("_"," ")}}
Talha Shah October 24, 2022

ah ok, and then can I do both the replace and split actions simultaneously in the for loop? Jira automation question.png

C_ Derek Fields
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 31, 2023

@Alex Koxaras _Relational_ - With respect to spaces, it turns out you can also get around this by entering your list as {{This has a space,This does too}} into the Smart Value field and then remove the {{ }}. This seems to work and doesn't require the additional use of replace

Jason Kane
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 9, 2024

This worked great for creating the items, but it doesn't seem to create the issues in the same order that the original variable is entered.  In looking at the example above, valueA was created as DSP-340 and ValueC is DSP-343, leaving ValueB most likely as DSP-344. 

Ideally valueA, ValueB, and ValueC would be DSP-340, DSP-343, and DSP-344 respectively.

Please let me know if there is a way to read the variable into the for loop and create in the same order. 

Raghu Mani April 24, 2024

How do I link the created tickets to the original one using the same automation, if its one issue, I can use the most recently created branch function to link it. But this already having a branch I do not see a way around.  Please advise

Nathan Phillip Brink April 24, 2024

@Raghu ManiIt might be better to create a separate question for that. Then you can share more details. I do not think there is enough detail here to give you a good answer.

I am not sure how you are creating the new ticket. However, I expect that, when creating the ticket, you should be able to specify links. I.e., you shouldn’t need a separate step after creating the ticket to create the link. You should just include the link in the ticket immediately. You might have to use an advanced JSON specification for the ticket to do that.

Raghu Mani April 24, 2024

Suggest an answer

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

Atlassian Community Events