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

Can conditional operators be used in emails created by Automation Rules? Edited

I asked support about this, but figured it might be of interest to the community. Original Summary:

Can conditional operators be used in emails created by Automation Rules to hide fields that are empty?

 

We would like to send email notifications where fields are displayed only if they are not empty.

I tried this:

{{#=}}IF({{issue.Desired Delivery Date/Time}}!="","<b>Desired Pickup Date/Time:</b> {{issue.Desired Delivery Date/Time}}",""){{/}}

And got this error:

Error rendering smart-values when executing this rule:
Unknown operator ':' at position 17: IF(2020-07-10T20:00:00.0+0000!="",<b>Desired Pickup Date/Time:</b> 2020-07-10T20:00:00.0+0000,)

I tried surrounding the value with quotes

{{#=}}IF({{"issue.Desired Delivery Date/Time}}"!="","<b>Desired Pickup Date/Time:</b> {{issue.Desired Delivery Date/Time}}",""){{/}}

And got this:

Error rendering smart-values when executing this rule:
Missing parameter(s) for operator !=: IF("2020-07-10T20:00:00.0+0000"!="","<b>Desired Pickup Date/Time:</b> 2020-07-10T20:00:00.0+0000","")

Are the Math operators even able to compare string values?

Thanks!

 

2 answers

2 accepted

1 vote
Answer accepted
John Funk Community Leader Jun 26, 2020

Hi Darryl,

I doubt Automation For Jira is going to be able to do what you have in there, but will let Support provide you with the expert response. 

Have you thought about filtering out those emails using JQL and then creating your Email rule just against the appropriate filter(s). You might need to create multiple rules to send various versions of the filters. 

Hi, yes, looking forward to what Support has to say.

To provide some context, this is a Rule happening On Create for a JSD project that has 6 different Request Types that have slightly different sets of fields.

So the email currently looks like this:

Hello ________ – thank you for your Services Request.

Summary: Move stuff into Lab
Description:
Unpack crates and move equipment into Lab

Requesting Department: Special Projects
Destination:
Desired Pickup Date/Time:
Desired Delivery Date/Time: 2020-06-30T13:00:00.0+0000

But for Services Requests, there is not a Destination or Pickup, so ideally those empty fields would be hidden.

I'm trying avoid having to create a separate email template for each Request Type, since they're *almost* the same except for a few fields. 

John Funk Community Leader Jun 26, 2020

You could do a single rule but have nested if/then statements for each Request Type. Then Copy and paste the email under each Request Type and edit out the fields that would be blank. 

Right, I know I could do it in one rule with if/thens. I guess I just miss Velocity templates. :-}

Like John Funk likes this

Good news from Support!

We recently added to support to conditional fields in automation actions and now you can perform some of those logic validations in the action item itself. The syntax would be something like that:

{{#if (issue.duedate.jiraDate.isNotEmpty()) }}
 test: {{issue.duedate}}
{{/}}

The following article will cover this in more details:

 

John Funk Community Leader Jun 26, 2020

That's awesome!! Thanks for seeing that through! Have you tried it yet? 

Indeed I did, and it works like a charm! The test code worked as advertised (although requiring jiraDate thing is a bit weird. But it definitely didn't work without it).

Other fields were more straightforward and worked fine.

Priority:

{{issue.description}}
{{#if (issue.priority.isNotEmpty()) }}
<b>Priority:</b> {{issue.priority.name}}
{{/}}

 Single-Select Field:

{{#if (issue.Destination.value.isNotEmpty()) }}
<b>Destination</b>: {{issue.Destination.value}}
{{/}}
John Funk Community Leader Jun 26, 2020

That's fantastic!

John Funk Community Leader Feb 07, 2021

Hey @Darryl Lee - CCC  - Can you click on the Accept Answer above so people will know there is a solution to this one? Thanks!

1 vote
Answer accepted

JIRA Support got back to me with this answer, which I'm going to mark as correct. :-}

 

We recently added to support to conditional fields in automation actions and now you can perform some of those logic validations in the action item itself. The syntax would be something like that:

{{#if (issue.duedate.jiraDate.isNotEmpty()) }}
 test: {{issue.duedate}}
{{/}}

The following article will cover this in more details:

Additionally, I successfully tested some other field types:

Priority:

{{issue.description}}
{{#if (issue.priority.isNotEmpty()) }}
<b>Priority:</b> {{issue.priority.name}}
{{/}}

 Single-Select Field:

{{#if (issue.Destination.value.isNotEmpty()) }}
<b>Destination</b>: {{issue.Destination.value}}
{{/}}

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

750 views 12 19
Read article

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