Pulling date in string with REGEX from Description trying to update date picker field, not working

Brittney Hinesly
Contributor
July 11, 2023

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 :))

1 answer

1 accepted

2 votes
Answer accepted
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2023

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?

Brittney Hinesly
Contributor
July 11, 2023

Hello Trudy,

 

The date that follows "Start Date:" will vary. I have not used Log Action before. I'll take a look. :) 

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2023

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.

Brittney Hinesly
Contributor
July 11, 2023

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!

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2023

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:"?

Brittney Hinesly
Contributor
July 11, 2023

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:"

Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2023

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+).*")}}

Screen Shot 2023-07-11 at 12.06.13 PM.png

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.

Like Bill Sheboy likes this
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 11, 2023

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

Like Brittney Hinesly likes this
Brittney Hinesly
Contributor
July 12, 2023

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.

Like Trudy Claspill likes this
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 12, 2023

Hm, perhaps you tested against different content than I used.

Suggest an answer

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

Atlassian Community Events