Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How do I split text strings in different places using smart values?

Callum Carlile _Automation Consultants_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 27, 2021

Hi all, I've got a string in a text field which looks something like

A001683R001S002L004

Using Jira automation (Cloud), I'd like to use smart values to split this reference up into sections and populate some hidden custom fields with these sections, so it would look like:

A001683 (custom field A) - first 7 characters
R001 (custom field B) - characters 8-11
S002 (custom field C) - characters 12-15
L004 
(custom field D) - characters 16-19

I assume I need to use the {{issue.field.split(... function but I'm not sure how to format this to split the string based off the number of characters, rather than by a (" ") or a (".") etc.

I can do the custom field edits and setting rule variables, it's just this splitting part which I'm stuck on. Any ideas would be much appreciated!

1 answer

1 accepted

0 votes
Answer accepted
Gareth Cantrell
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 27, 2021

@Callum Carlile _Automation Consultants_ if the text string is always a fixed length and the character position remain the same, I'd use the .substring(start, end) function.

{{issue.field.substring(0,7)}}
{{issue.field.substring(7,11)}}
...
Callum Carlile _Automation Consultants_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 27, 2021

Thanks @Gareth Cantrell this is exactly what I was looking for - works like a charm!!

David Washburn
Contributor
August 1, 2023

Hi @Gareth Cantrell sorry to bring back an old thread but I am trying to perform this task except the strings are not always fixed length. They are comma separated (for example Label1,Label2,Label3) and could be random length labels. Is there a way to do this if you don't know the exact length of each value that will be returned?

Gareth Cantrell
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.
August 1, 2023

Hi @David Washburn ,

What you want for that is the .split() function. 

The below code will split the string into a list using a comma as the separator:

{{issue.fieldX.split(“,”)}}

You can use the list.get(index) function to get the item at a specific index. 

E.g.

{{issue.fieldX.split(“,”).get(1)}}

will retrieve the 2nd value from the list. 

Seema Sharma February 21, 2025

I'd like to do something like this but using mobius Jira. I have a custom field that contains text which is separated by "---" and I'd like to see this separated in a table in a dashboard. how would I go about doing that please?

Suggest an answer

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

Atlassian Community Events