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?
@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.
@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'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.