Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

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,556,708
Community Members
 
Community Events
184
Community Groups

Automation compare Variable to date

I am trying to get an automation to work.

I have set a variable and used Reg ex to get the data from the description.

{{issue.description.match("date created: ?(.*)")}}

What I want to do is an Advanced Compare condition to say if by variable is after today.

I can not get it to work. Im guessing that my date formats are not correct but don't know where to look.

 

Can anyone help

2 answers

So I have got it working so just in case anyone has a similar requirement

In the Description of the ticket I had 

date created: 2021-01-17

In Automation I create a variable called createddate as follows

{{issue.description.match("date created: ?(.*)").toDate.jiraDate}}

 I also created a variable called datetoday

{{now.jiraDate}}

 I can then do and Advance compare condition that says

{{createddate}} equals {{date today}}

 

Granted in the request was to do greater but I realised that in my use case I actually needed equal. I have not tested but I assume I could change it to be greater than and it should work.

 

Thanks for the help however.

bmccoy
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Jan 19, 2021

Hi Peter,

Glad to hear you got it working.  I think if you want to do a greater than comparison, you will need to use the date functions for the comparison and check for true/false values

The advanced condition will look a bit like

{{issue.description.match("date created: ?(.*)").toDate.isAfter(now)}}

 equals

true

 Cheers,
Brydie

Thanks @Peter Weir - this has help me. I have upvoted as answer. Thank you

0 votes
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jan 18, 2021 • edited

Can you provide a sample of what the issue description might look like? It's hard to debug regexes without the source data.

I think the problem is that question mark before the (.*). Question marks usually follow + or * quantifiers to designate that they should be "non-greedy". But assuming "date created:" is on a line by itself, you don't need to worry about any of that. Assuming your issue description looks something like this:

Description of issue

date created: 18/Jan/2021

other field: foo

another field: bar

Then this would work:

{{issue.description.match("date created: (.+)")}}

So, I tested this by creating a rule with a Manual trigger that can only by run by Administrators/Site Admins, etc.

The rule has one action: Log action where you would put the smart value you're testing.

Then you go to a test issue, click on Automation -> Rule Execution, and test it out. You'll want to watch/reload the log and keep tweaking the regex until you get what you're looking for.

And yes, you will probably need to worry about Date formats. You can read all about that here: https://support.atlassian.com/jira-software-cloud/docs/smart-values-date-and-time-functions/

The same testing process would work to get your dates formatted in a way that they can be accepted by an actual date field.

Also, if your regex becomes more complex, I recently used this online tester which lets you interactively try out regexes, which is really handy:

https://www.freeformatter.com/java-regex-tester.html

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events