Trying to iterate over a single line text field and split out the values

Jordan Dowdy October 26, 2023

I'm using Jira automation to try and split out a single line text field to use each value in the list. So far I've been able to successfully split at each "," but can't quite figure out how to print the value at each iteration.

{{#webResponse.body.fields.customfield_10881.split(",")}} {{body}}.com{{^last}},{{/}}{{/}}

In the above line I have tried logging with {{body}} but am not getting any values returned. The automation does correctly iterate and logs the following: 

.com, .com, .com, .com, .com, .com, .com

The custom field just contains a single line comma separated list. 

Does anyone have experience with this particular issue?

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.
October 26, 2023

Hi @Jordan Dowdy -- Welcome to the Atlassian Community!

 

For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected.  Those will provide context for the community to offer ideas.  Thanks!
 
Until we see those...

Please try adding a write to the audit log with the following, as it will confirm the fields / attributes you are referencing in your expression match what you expect:

web response body: {{webResponse.body}}

 

Kind regards,
Bill

Jordan Dowdy October 26, 2023

The action I'm troubleshooting at this time is strictly the logging. I added a log for the web response body but narrowed to only the relevant custom field. In the API issue view it looks exactly the same. It's just a single line of text that I need to split out and append the second log item to each item in the first list. customfield.jpg

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.
October 26, 2023

Thanks for that information.

Based on the audit log, the field appears to already be a list in the response.  Please try removing the split(",") to observe what happens.

And, as you appear to be creating a URL, you may want to add the trim() function if you observe any extra characters: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#trim--

Jordan Dowdy October 26, 2023

I removed the split and the log contains one instance of .com, indicating it just printed the same value for each time it iterated. What I need is a way to reference the item being iterated on for each .com, instance. This is why I tried calling {{body}} which prints nothing. I'm not sure how to reference the current item being iterated. 

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.
October 26, 2023

Two things to try...

If that field in the response is text, and not structured, after using the split there is no {{body}} attribute: only text.  In that case, please replace that {{body}} with {{.}} as that is the generic way of returning whatever value the iterator is returning.

{{#webResponse.body.fields.customfield_10881.split(",")}} {{.}}.com{{^last}},{{/}}{{/}}

 

Another thing to try: if that response is text and the delimiter is actually a comma followed by a space, rather than just a comma, you could try splitting on ", "

Jordan Dowdy October 26, 2023

Both of those solutions combined provided the desired result, thank you!!!

Like Bill Sheboy likes this

Suggest an answer

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

Atlassian Community Events