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?
Hi @Jordan Dowdy -- Welcome to the Atlassian Community!
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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--
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 ", "
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Both of those solutions combined provided the desired result, thank you!!!
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.