Carriage return between values in a field (using JQL)

dennish_dcsorg_com June 22, 2021

I'm running some automation that displays any items that were checked off for a custom multi checkbox. The default way it displays is each value separated by a comma. Ideally I'd like for each item to be displayed on a new line. Can I format it so it displays that way?

 

So right now I have:

Service {{issue."Services affected"}}

and when the automation runs and send the email it shows:

item1, item2, item3, item4

I'd like it to be:
item1
item2
item3
item4

2 answers

1 vote
Egor Zvorykin August 26, 2021

Here's how I did it

{{#issue."Services affected"}}Service {{.}}{{^last}}

{{/}}{{/}}

The "^last" block (starting with `{{^last}}` and ending with `{{/}}`) is included for all elements except the last. Inside this block there is a newline.So for all the items except the lines the newline will be added at the end.

`{{.}}` signifies a current item when iterating.

Reference: https://support.atlassian.com/jira-software-cloud/docs/smart-values-lists/

0 votes
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.
June 22, 2021

Hi @dennish_dcsorg_com 

You mention solving this with automation.  Have you tried to either use the replaceAll() function to substitute a newline for the commas, or use split() and join() to do the same thing?


Best regards,

Bill

dennish_dcsorg_com June 22, 2021

Can you assist with what the syntax for that would be? I'm not the expert on smart values in JA.

 

This is the actual line I'm using to display the checked values.

 

Service {{issue."Services affected"}}

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.
June 22, 2021

Hi @dennish_dcsorg_com 

A lot about using automation rules is experimentation, so I encourage you to try things to learn what does and doesn't work.  The documentation will not have all of the answers for every use case, so consider writing a rule, and if you have a problem then post that rule and the audit log for the community to offer help.

To do what I was suggesting, you could:

  • use the Create Variable action to save the field.  This will convert it into a string with comma-separated values.  For example, you could name the variable: varServicesAffected
  • next you can use the replaceAll() text function to substitute the commas for newline characters to produce the list.  For example:
{{varServicesAffected.replaceAll(",", "\n")}}

 

Best regards,

Bill

Like # people like this
Glenn Wyatt March 13, 2024

The create variable method seems a bit much when you can easily use the join syntax: 

{{issue.Services affected.join("<br> </br>")}}

 

Result: 
item1
item2
item3
item4

Suggest an answer

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

Atlassian Community Events