Create an array of keys from lookupIssues

Jó Sales de Medeiros Júnior
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!
May 8, 2024

 

Hello,

Using Jira Automation, I'm trying to add all issues from a JQL search to a sprint that hasn't started yet.

According to the Rest API documentation, this can be done by making a POST request to the path "/rest/agile/1.0/sprint/{sprintId}/issue", sending the issue keys as an array.

My difficulty lies in how to implement the request in Jira Automation, transforming the values of the variable {{lookupIssues}} into the format:

 

"issues": [
    "PR-1",
    "10001",
    "PR-3"
]
I appreciate any help.

1 answer

1 accepted

0 votes
Answer accepted
Bill Sheboy
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.
May 8, 2024

Hi @Jó Sales de Medeiros Júnior -- Welcome to the Atlassian Community!

Some of the helpful documentation on list iteration, such as for Lookup Issues, is not all in one place.  If you look at the bottom of the section on lists, there are many helpful examples: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/#Combined-function-examples

For what you are trying, you want the keys in quotation marks, separated by commas.  One way to do that would be this:

"issues": [
{{#lookupIssues}}"{{key}}"{{^last}}, {{/}}{{/}}
]

That part with {{^last}}, {{/}} adds a comma followed by a space for each issue except the last one.

Kind regards,
Bill

Jó Sales de Medeiros Júnior
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!
May 8, 2024

Perfect, Bill Sheboy

Thank you very much for your help.

Like Bill Sheboy likes this

Suggest an answer

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

Atlassian Community Events