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
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks @Peter Weir - this has help me. I have upvoted as answer. Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.