Automation for Jira smart value display field only when not empty

Ayelet Ben-Tzur November 18, 2020

Hello,

I'm sending an email via automation for Jira. For each field appearing in the email I have a title and the field content, but I want them to appear only if the field is not empty. Meaning, if field xxx is not empty I will see

xxx: content

if it  is empty, I won't see that row at all.

Any suggestions?

2 answers

1 accepted

2 votes
Answer accepted
Mark Chaimungkalanont
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 22, 2020

Hey there Ayelet

You should be able to use this format to display fields only when there is a value. The example below is for a field called "Select"

{{#issue.Select}}
Select: {{.}}
{{/issue.Select}}

You can use the same patterns for multiple different fields to only show the labels when you need to

Hope that helps! 

Ayelet Ben-Tzur November 22, 2020

WOW Mark, this is great! Works like a charm. 

Thank you so much, you just saved me hours of work! 

Ayelet Ben-Tzur November 23, 2020

*editing*

Please ignore, I made a mistake time and time again so it didn't work. All good now even with checkbox field :)

______________________

@Mark Chaimungkalanont  BTW, this doesn't work for checkbox field, I also tried {{#issue.customfield_xxxxx.value}} but nope.. any idea?

Like John Funk likes this
1 vote
John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 18, 2020

Hi Ayelet,

You would need to incorporate a series of Conditions to check check if each field is empty. 

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.
November 18, 2020

Hi @Ayelet Ben-Tzur 

There is no in-line if/else structure that you can use within the action Send Email, so the conditions John notes will help.

In addition, you could also use conditions with create variable to build up the message first, and then put them into the email message. CORRECTION: Sorry, as I just noticed you are using server version, so create variable doesn't exist yet for that one.

Best regards,

Bill

Like Ayelet Ben-Tzur likes this
Ayelet Ben-Tzur November 18, 2020

Thank you both!

If I can't use variables, conditions won't help me. I mean, I check if a field is empty in a condition and then what?

Is there a way to just add all the issue fields into the email's body, instead of calling them one by one and maintain them forever?

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 19, 2020

Actually, that's what I do - I don't use any labels/headings for the fields, but just list the issue fields themselves. 

It the scenario of using conditions, you would have If then else logic for each field is empty condition and then the email for that condition. You would have to copy and paste the email x number of times for each if statement though. It would get unruly with several fields but not with a handful. 

Like Ayelet Ben-Tzur likes this
Ayelet Ben-Tzur November 19, 2020

Thank you @John Funk . It means that if I have 20 fields, I will need 20 email actions? I think I prefer maintain the automation if I will have a new field in the future.

So as I understand, there's no way of getting all issue's fields automatically, something like {{issue.fields}}?

John Funk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 19, 2020

Yes to the first question and No to the second question. 

So your email could look like:

{{issue.field 1}}

{{issue.field 2}}

{{issue.field 3}}

{{issue.field 4}}

{{issue.field 5}}

etc. 

But if there is no value in fields 5, 6, and 7 there would be a big gap between line 4 and line 8 - they would not move up. 

But I would see no problem with you putting the field labels in front of each one and if it is empty, it's just empty. 

Like Ayelet Ben-Tzur likes this
Ayelet Ben-Tzur November 19, 2020

Yes, exactly.

Thank you for all your help! I guess there are no shortcuts on this. If I will have any shocking news, I'll update.

Like # people like this
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.
November 19, 2020

Hey guys, one work-around for server not having Create Variable for working space is to use a custom field.  The downside is that after each change, you would need to perform a re-fetch...making the rule much slower.

To add onto John's idea, if you pause to consider which fields *could* be empty, that may help you reduce the number of if/else patterns that you need.

Like Ayelet Ben-Tzur likes this

Suggest an answer

Log in or Sign up to answer