I am currently utilizing Automaton for Jira LITE to handle incoming issues from emails. In the issue description, there is a date in a form of a string which I extract with a regex using match(). I can convert the string into a date object using .toDate. However, the converted object is not the correct date.
For example, one of the descriptions has a date of "September 3, 2019". I used .toDate("MMMM d, YYYY") to convert it to a date object with the correct format. I then format that date further to .format("d/MMM/yy"). It should spit out 3/Sep/19. The actual output is 30/Dec/18. When put it into a different format like yyyy-mm-dd, it spits out 2018-00-30. I've also tried changing the month in the description in July, same result. My guess is that my string format may cause Automation to read it incorrectly.
Could this be related to how I've extracted the string via regex from the description? Should I try formatting the extracted string in a certain way so Jira/Automation can read it correctly?
Hi Hieu,
I think we may need to break this down step by step. Use a log action or add comment with the following:
Parse: {{description.match("regex")}}
Date: {{description.match("regex").toDate}}
Date Format: {{description.match("regex").toDate.as("d/MMM/yy"}}
That should hopefully show us where it is breaking.
Cheers,
Nick
Hey Nick,
Thanks for replying.
Here is my output with the regex pulling "July 3, 2019" -
Parse: July 3, 2019
Date:
Date Format:
I believe .toDate requires you to match the format of the string which is why I used .toDate("MMMM d, yyyy") to get an output for that function. Else, it comes up empty as you can see above.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I figured out what I did incorrectly -
Seems like there is a difference between YYYY and yyyy when formatting the year for turning a string into a date object.
.toDate("MMMM d, yyyy") was what I needed to use.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm effectively trying to do the same as Hieu here. However, when doing so, I'm only getting the following back:
Parse: June
Date:
Date Format:
Here's what I have in my automation:
Parse: {{issue.description.match("(January|February|March|April|May|June|July|August|September|October|December) (\d{2}), (\d{4})$")}}
Date: {{issue.description.match("(January|February|March|April|May|June|July|August|September|October|December) (\d{2}), (\d{4})$").ToDate}}
Date Format: {{issue.description.match("(January|February|March|April|May|June|July|August|September|October|December) (\d{2}), (\d{4})$").toDate.as("yyyy/MM/dd")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Hieu Phan this has been here a while but I'm hoping you can help me on a similar issue.
I'm currently pulling information from the description field using REGEX due to it being an email request. My goal is to populate the fields from my REGEX pulls.
I'm having trouble getting the "Start Date" date picker field to update with my code.
The description displays it as:
Start Date: 7/11/2023
My Automation is
If: matches
First Value: {{issue.description}}
Condition: Contains Regular Expression
Regular Expression: (?<=Start Date:)(\W\d+\\\d+\\\d+)
Then: Edit Issue Fields
Field to Set: Start Date
and this is my smart value:
{{issue.description.match(".*(?<=Start Date:(\W\d+\\\d+\\\d+).toDate("m/dd/yyyy").*”)}}
I know it's wrong, I just don't know where or how to correct. If you have any idea please let me know :))
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What error message you get in audit logs of your automation?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello
I've changed it a little bit and finally got it to go through as "Success" in the Audit log but no change to my Start Date field.
My code is :
If: matches
First Value: {{issue.description}}
Condition: Contains Regular Expression
Regular Expression: (?<=Start Date:\W*)(\d+\/\d+\/\d+)
Then: Edit Issue Fields
Field to Set: Start Date
{{issue.description.match(".*(?<=Start Date:)(\W\d+\/\d+\/\d+).toDate().*")}}
when I attempt the last bit of code like this
{{issue.description.match(".*(?<=Start Date:)(\W\d+\/\d+\/\d+).toDate("MM/dd/yyyy").*")}}
I get an error :
Error rendering smart-values when executing this rule:
Failed to get value for issue.description.match(".*(?<=Start Date:)(\W\d+\/\d+\/\d+).toDate("MM/dd/yyyy")*"): {{issue.description.match(".*(?<=Start Date:)(\W\d+\/\d+\/\d+).toDate("MM/dd/yyyy")*")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Alright I figured it out.
If: matches
First Value: {{issue.description}}
Condition: Contains Regular Expression
Regular Expression: (?<=Start Date:\W*)(\d+\/\d+\/\d+)
Then: Edit Issue Fields
Field to Set: Start Date
{{issue.description.match("(?<=Start Date:\W*)(\d+\/\d+\/\d+)").toDate("MM/dd/yyyy").format("yyyy-MM-dd")}}
This worked for my Start Date field which is a date picker.
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.