Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,373
Community Members
 
Community Events
165
Community Groups

Jira Automation - If-Else-JQL Condition with date comparison

Edited

Hi Atlassian Community,

 

I am running into an issue with an if-else condition. The automation needs to match a new comer joining date from one task description (issue.parent.Join Date) against today's date (now.jiraDate) to see if it is greater or equal to, and then perform a task.

The idea is to create tasks when they are needed (i.e. in sequence) and not all at the same time.

The automation rule:

1. Run everyday with JQL condition: Summary ~ "onboarding" and assignee = "Person1"
 
2. Then I do a match of today against the onboarding date from the task description (minus 21 days) because it needs to be 3 weeks before the a new person joins:
 
If block: {{issue.parent.Join Date.minusDays(21)}} = {{now.jiraDate}}
  • If match, then create a sub-task

3. Same here but with one week ahead

Else-if block: {{issue.parent.Join Date.minusDays(7)}} = {{now.jiraDate}}

  • If match, then create another sub-task

4. And here after he/she joined

Else-if block: {{issue.parent.Join Date}} <= {{now.jiraDate}}

  • If match, then create a sub-task
  • And another task

5. Else -> This should do nothing

  • add value to audit log: Do Nothing

Error: I am receiving this error and not sure if it is an issue with the logic or format of the dates?

Date Matching Issue 1.PNG

 

Here my automation process:

InkedDate Matching Issue - automation 1_LI.jpg

InkedDate Matching Issue - automation 2_LI.jpg

2 answers

1 accepted

0 votes
Answer accepted

Hi @Maxim Bode 

The error message is indicating that your JQL in the conditions is failing, with the left side collapsing to null.  For example: {{issue.parent.Join Date.minusDays(21)}} = {{now.jiraDate}}

First thing: I could confirm the smart value for that custom field, such as using this how-to article: https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/

 

Next thing, I would write this to the audit log to determine if there is a value in the field:

{{issue.parent.Join Date}}

My understanding is that not all fields of parent are directly accessible this way.  If they were, imagine a scenario of {{issue.parent.parent.parent.someField}} whereby the rule needs to have all the possible data in the issue's hierarchy available.

If it is empty, the work-around is to branch to the parent and grab the date, storing it in a created variable.

 

Next, it is possible that syntax for the JQL condition is the problem, and so that could be addressed by instead using an advanced compare condition and using diff() then checking the result:

  • first value: {{issue.parent.Join Date.diff(now).days}}
  • condition: equals
  • second value: 21

 

Kind regards,
Bill

Thanks Bill for the comprehensive answer.

I changed the rule using an advanced compare condition and now this is working fine.

Kind regards,

Maxim

Like Bill Sheboy likes this
0 votes

Hi Maxim.

What doe the JQL look like in your trigger "Schedule" step? That's where it looks like the culprit is according to your logs.

Hi Garrett, 

the JQL in the trigger is: Summary ~ "onboarding" and assignee = "Person1"

 

Hope this helps for further investigation.

Best

Maxim

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
Community showcase
Published in Jira Software

Upcoming changes to epic fields in company-managed projects

👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...

14,098 views 34 44
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