Heads up! On March 5, starting at 4:30 PM Central Time, our community will be undergoing scheduled maintenance for a few hours. During this time, you will find the site temporarily inaccessible. Thanks for your patience. Read more.

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

Replacing date in the summary field with a date from a date field using smart values and regex

Steve Rhodes
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 20, 2024

I have a use case where I want to replace the date in a summary with the date from a date field in the same issue. I have a not-quite-working automation, with help from @Bill Sheboy  here: https://community.atlassian.com/t5/Jira-questions/Update-summary-with-updated-due-date/qaq-p/2329197

But, the regex of (in the example linked post)

{{issue.summary.replaceAll("(\(.*\))",issue.duedate.format("(MM/dd/yyyy)"))}}

doesn't quite work and my date format is yyyy-MM-dd and despite changing the regex in the replaceAll to

{{issue.summary.replaceAll("(-(.*-))",issue.customfield_15528.format("yyyy-MM-dd"))}}

the summary of "2024-11-20 Summary text" here gets replaced with "20242024-11-21y text" with the new date being 4 characters out of place to the right and overwriting half of the date and some of the summary text.

I cannot seem to get the regex in the replaceAll working properly.

2 answers

1 accepted

2 votes
Answer accepted
Steven Rhodes
Contributor
November 21, 2024

I fixed it by completely replacing the Summary field from the available fields in the issue instead.

{{issue.customfield_15528.format("yyyy-MM-dd")}} Summary Text 

Such a simple idea, i dont know why i was trying to replace the existing Summary! Jut completely overwrite :) 

0 votes
Marc - Devoteam
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 20, 2024

Hi @Steve Rhodes 

I think you might miss a ( in the smart value clause, in front of yyyy.

I see 4 ( opens and 5 ) closers in your value.

{{issue.summary.replaceAll("(-(.*-))",issue.customfield_15528.format("(yyyy-MM-dd"))}}

Could it be the missing (?

Steve Rhodes
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 20, 2024

I think I may have worked it out. The replaceAll is replacing the contents of everything between the brackets - in the original case (30/10/2024), as this is the

(\(.*\)

part in the regex. In my example I mistakenly misread the slashes and changed the characters to recognise for the replace. In this case i put in the - to replace contents between. So, this is why I got 20242024-11-21, as it replaced the - with the date i extracted from the field.

As I don't have any identifier characters to start the insertion point, it would be ok if it just overwrote the date at the beginning of the Summary. Need to work out how to do that.

Like Marc - Devoteam likes this

Suggest an answer

Log in or Sign up to answer