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?
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
*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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ayelet,
You would need to incorporate a series of Conditions to check check if each field is empty.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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}}?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.