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 :))
Hello @Brittney Hinesly
Will that be the only date in the field, or do you need to find the one that specifically follows the "Start date:" text?
Have you used the Log action in your Automation to see what you are actually getting for the regex and the smart value?
Hello Trudy,
The date that follows "Start Date:" will vary. I have not used Log Action before. I'll take a look. :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I understand the value of the date itself may vary.
I'm asking if there could be multiple dates in the Description field.
Will your date always have 4 digits for the year?
Will it always use / as the separator?
Will it always be m/d/y or might it be d/m/y?
To find out if your Description field contains text anywhere is it that matches the pattern of
Start Date:<any number of non-alphanumeric characters><a date using forward slash as a separator>
...with any or no text preceding or following the above, you can use this regex:
.*Start Date:\W*\d+\/\d+\/\d+.*
That would work for your Condition.
I'm still working out how to extract the date itself to then use in another field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh I'm sorry, I understand now. Yes, it will come through as the same format every time with month / day/ year(4 digits) with nothing preceding or following after.
Thank you, I'll keep an eye out for your response. I appreciate your help!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So, there will only ever be one date in the Description field and you always want it?
Or, can there be more than one date in the field?
Do you only want the date when it follows "Start Date:"?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There will be multiple dates in the description field that follow other context like End Date: 1/25/2001 or Request Date: 1/02/2001 etc.. I only want the date that follows "Start Date:"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This works for extracting a date that follows "Start Date:", regardless of any text that comes before "Start Date:" or after the date.
{{issue.description.match(".*Start Date:\W*(\d+\/\d+\/\d+).*")}}
That gets the date as a text string, so then conversion would have to be used to format it for use in a Date field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You might find this site useful for testing regex expressions that you want to use in Jira Automation Rules.
https://www.freeformatter.com/java-regex-tester.html#before-output
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I couldn't get it to work the way you had suggested but I did get it to work.
Here's what I had setup for my If statement:
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.
Hm, perhaps you tested against different content than I used.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.