Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Formatting a smart value list (for email) to say "Service1, Service2, and Service3"

Victoria T
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 17, 2022

I'm trying to format a smart value list to stick it into a sentence for an email. I have an idea of what I will need to do with conditional logic (i.e. if there is one item, = do this, 2 = do this, 3 or more = do this) but where I'm stuck is formatting the "3 or more" section.

To be readable, I'd like to make it say "Service1, Service2, and Service3" with the "and" instead of another comma being where I'm struggling. I've been looking through documentation and I can't find anything, but it feels like something that might just be expected to know.

After digging around, what I've reached is:

{{#issue.affectedServices}} {{name}}{{^last}}, {{/}}{{/}}

Where I understand by putting "{{^last}}" it's saying do not put the comma after the last item in the list. What I don't understand is how to make it put an "and" in front of the last item of the list instead of a comma after the item.

Thank you!

1 answer

1 accepted

2 votes
Answer accepted
Mykenna Cepek
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.
February 17, 2022

Try this:

{{#issue.affectedServices}} {{#last}}and {{/}}{{name}}{{^last}}, {{/}}{{/}}

Omitting the final comma (before the 'and') is not easy, and arguably not desired (Oxford comma).

Mykenna Cepek
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.
February 17, 2022

See the docs here for examples.

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.
February 17, 2022

Hi @Victoria T 

Yes, and...to what @Mykenna Cepek suggests...

You could also look at the conditional logic and/or new smart value list filtering for more complex formatting: 

For example, you could use a test on {{issue.affectedServices.size}} to check the count for different layouts, concatenating them for 0 values, 1-2 values, or more than 2 values.  Because only one would be non-empty you would get the expected result.

Kind regards,
Bill

Victoria T
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 17, 2022

@Mykenna Cepek Thank you! This is the exact sort of example I needed to understand what to do next. And you're right, I don't particularly care if the comma before "and" is committed or not. :)

@Bill Sheboy Oh yes, I'm having fun with the conditional logic for these rules. To anyone that might see this, .size is how I'm doing it and it's working.

Like Bill Sheboy likes this
Mykenna Cepek
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.
February 17, 2022

And if the Oxford Comma (or not) isn't pedantic enough for you, wait until you find yourself spending time adding a conditional to pluralize a word when the count is not equal to "1"!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events