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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Automation for Jira smart value display field only when not empty

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

1 vote
Answer accepted

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! 

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

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

*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 Nov 18, 2020

Hi Ayelet,

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

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

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 Nov 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

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}}?

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

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

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
DEPLOYMENT TYPE
SERVER
TAGS
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,022 views 8 28
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you