Smart Value substringBeforeLast(String separator) question

Sebastian Monsalve
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 22, 2025

Hi Jira Gurus, 

I'm working with Jira Automation using Smart Values. I intend to extract a substring that ends with colon ":", hence I am using: 

{{issue.summary.substringAfterLast(":")

However, the string does not contain the actual last colon, I wonder if there is a way that can contain it or add it at the end of the substring. 

In my last attempt, I tried using Concat function like this:

{{issue.summary.substringAfterLast(":").concat(":")

But the actual result that came out of that was only the colon character : in the issue summary filed. 

I need to clone the Issue summary to another ticket based off on certain criteria, but essentially, I need to drop off the last part of the summary that contains the sprint name, which is just right after the ":" colon character. 

Any ideas?

1 answer

1 accepted

2 votes
Answer accepted
Bill Sheboy
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.
January 22, 2025

Hi @Sebastian Monsalve -- Welcome to the Atlassian Community!

Would please post an example summary that does not work as expected and an image of the rule action using that smart value expression?  Those will provide more context for the community to offer better suggestions.  Thanks!

Kind regards,
Bill

Sebastian Monsalve
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 22, 2025

Sure, I hope this helps:

Summary: [A4 - Team] A4 Training sessions: A4-Sprint 25Q3-3

Action: Clone issue with new Summary as 

{{issue.summary.substringAfterLast(":")

Result: [A4 - Team] A4 Training sessions

Desired Result: [A4 - Team] A4 Training sessions: 

Screenshot_2.jpg

 

Bill Sheboy
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.
January 22, 2025

Thanks for that information, and it appears you are using Jira Data Center version.

 

First, your smart value expression is missing the closing, double-curly brackets }}

Next, I am a bit confused by what you show as the substringAfterLast() should have returned this:

 A4-Sprint 25Q3-3

Did you instead want to use substringBeforeLast?

In that case, please try this:

{{issue.summary.substringBeforeLast(":").concat(":")}}

 

Like # people like this
Sebastian Monsalve
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 22, 2025

Hi Bill, 

Yes you're right, I must had change it to AFTER a moment ago while I was doing some experiments. 

But the last case posted there, worked like a charm. 

Thank you!

Like Bill Sheboy likes this
Bill Sheboy
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.
January 22, 2025

Awesome; I am glad to learn it is working!  Please consider marking this question as "answered" to help others with a similar need find solutions faster.  Thanks!

Like # people like this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events