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!
@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)}}
...
Thanks @Gareth Cantrell this is exactly what I was looking for - works like a charm!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.