What is Jira JMWE nunjucks syntax for Conditional execution on an empty field?

We are using Jira Cloud with JMWE (Jira Misc. Workflow Extensions).

Question: what is the nunjucks syntax to determine if custom date/time field is empty?

Ultimate goal is to create a Jira ticket in another project on a workflow transition when ("Vertical" = Air or Hotel) + ("Opportunity" = P1 or P2) + ("Date First Set Live" = empty)

Where:
1) "Vertical" is an optional single select field with values: Air, Hotel, Tourism, ...)
2) "Opportunity" is an optional single select field with values: P1, P2, P3, P4, PH3, ...)
3) "Date First Set Live" is a date/time field that gets set by a workflow transition and is not editable by users. The value is empty or looks like: 24/May/17 11:43 AM


I believe I have the syntax part for the conditional execution of Vertical & Opportunity working:
({{ issue.fields['Vertical'].value == "Air"}} || {{ issue.fields['Vertical'].value == "Hotel"}}) && ({{ issue.fields['Opportunity Priority'].value == "P1"}} || {{ issue.fields['Opportunity Priority'].value == "P2"}})


I am starting with a simple test to get the syntax right for "Date First Set Live" is empty. The Nunjucks test always results in "True" or "False" for both examples (one has a value and the other is empty).

Example (use cases):
   KEY-2217 has "Date First Set Live" = 24/May/17 11:43 AM
   KEY-3353 has no value for "Date First Set Live"

Things I tried:
1) {{ issue.fields['Date First Set Live'].value == null}} ==> both examples = True
2) {{ issue.fields['Date First Set Live'].value != null}} ==> both examples = False
3) {{ issue.fields['Date First Set Live'].value == ""}} ==> both examples = False
4) {{ issue.fields['Date First Set Live'].value != ""}} ==> both examples = True
5) {{ issue.fields['Date First Set Live'].value < (now)}} ==> both examples = False
6) {{ issue.fields['Date First Set Live'].value === ""}} ==> both examples = False


Any help on how to get the right syntax for checking a null/empty value would be appreciated.

 

1 answer

1 accepted

I believe I've figured this out on my own.  Posting the results in case it can help others.  By removing the ".value" on the syntax, the condition shows True or False correctly for fields that are empty.

e.g.  {{ issue.fields['Date First Set Live'] == null}}

The overall syntax for my example:  ({{ issue.fields['Vertical'].value == "Air"}} || {{ issue.fields['Vertical'].value == "Hotel"}}) && ({{ issue.fields['Opportunity Priority'].value == "P1"}} || {{ issue.fields['Opportunity Priority'].value == "P2"}}) && ({{ issue.fields['Date First Set Live'] == null}})

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

354 views 0 6
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you