Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to Parse a List of Approvers in an Automation?

John January 23, 2023

I am trying to parse a list of users in an email Automation such that I can pull each approvers email address:

{
  "recipients": [
    "{{issue.Approvers.emailAddress.split(", ")}}"
  ]
}

The behavior I am getting back is that ['[email1], [email2]']

 

The desired result from parsing is a list of strings, IE

['email1', 'email2', 'etc']

 

How can I get the above behavior?

1 answer

1 accepted

1 vote
Answer accepted
Kian Stack Mumo Systems
Community Champion
January 24, 2023

@John

Maybe this is a silly question.. Why do you need to parse the emails that way? When I try to set up an email action automation rule, I can add the user picker in the recipients list without worrying about parsing.

Screen Shot 2023-01-24 at 2.47.15 PM.png

John January 25, 2023

I am not trying to send an email, I am trying to parse this list to utilize these emails in a web POST request.

Kian Stack Mumo Systems
Community Champion
January 26, 2023

@John, I didn't know what exactly the form is that you wanted, so I put a few options together for you: 

[{{issue.Approvers.emailAddress}}] returns [email1, email2]

[{{#issue.approvers.emailAddress}}'{{.}}'{{^last}},{{/}}{{/}}] will return ['email1', 'email2']

{{issue.Approvers.emailAddress}} returns email1, email2

{{#issue.approvers.emailAddress}}'{{.}}'{{^last}},{{/}}{{/}} returns 'email1', 'email2'

John January 26, 2023

Hi Kian,

 

Thanks for the reply. My understanding is that the logic for a call like:

[{{#issue.approvers.emailAddress}}'{{.}}'{{^last}},{{/}}{{/}}] will return ['email1', 'email2']

 

Is such that we are only grabbing the first and last email in a list and that is the function of {{.}}{{^last}} in this case. Is this understanding correct?

I am struggling to find documentation that defines the function of # and {{/}} in Jira Automation

This is the desired format that I would want the response to be in. Can I iterate through the entire list of approvers to get a similar output for N emails using the logic of this line, or do we have to manipulate it further?

Kian Stack Mumo Systems
Community Champion
January 26, 2023

Hi @John, for more information about lists, check out this documentation.

Basically what we are doing is pulling out the list of emails from the approvers field and telling Jira to surround each value with the single quote character ('). That is this portion of the smart value

[{{#issue.approvers.emailAddress}}'{{.}}'{{/}}]

 

If you were to run the line above, you would get an output of ['email1''email2''email3'...], which is close, but not what you want.

 

To introduce the commas between each value, we need to tell the list to also add a comma after every value that is not the last value in the list.

 

That part of the command is this - {{^last}},{{/}}. If you put them together, it tells Jira to print out every value and surround it with the quote characters, and for all but the last one, append a "," to the end.

Does that make sense?

Suggest an answer

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

Atlassian Community Events