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.
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}})
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.