Split function not working in Jira automation for a custom field

Thushan Kalhara Withanage March 22, 2022

There is a custom field called Reported Version and there is a value field under it. Need to split the column by "." character to compare the last part with a constant in an automation function.

 

Custom field name : "Reported version"

Field structure in Rest API : 

"customfield_15753":

{
"self": "some value",
"value": "A.B.0",
"id": "1111"
}

 

Tested with following. But it does not work as expected.

{{issue.fields.customfield_15753.value.split(".").get(2) = "0"}}

2 answers

3 votes
José Nogueira September 8, 2024

Hi @Thushan Kalhara Withanage 

I struggled with the same issue, and decided to share here although it's a quite old post.
It appears that split, replace, left, ... functions do not work for custom fields.

This is the way I managed to make it run: use a smart value variable in between...

  1. Create a smart value variable with the custom field content populated
  2. Use the split, replace, left, ... functions on the smart value variable
  3. Use the smart value variable anywhere in your automation (e.g. change an AQL attribute in my sample pic)

Jira_CF_split.jpg

Hope this helps someone, and do share better methods that anyone might have.

 

Thanks and cheers

Pablo R
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!
December 19, 2024

Hi @José Nogueira , 

It makes no sense that we need to go to such an extent, but your solution works !

I was struggling with the "from" object from the changelog, it felt like it's neither an array (I couldn't loop through its element), nor a string (I couldn't split it to turn it into an array)

But storing it into a variable, ex :

{{changelog.myCustomField.from.remove("[").remove("]")}}

 allowed me to save the IDs as a comma-separated string (without the brackets), ex : 

1234,1235,1236

on which I could finally get an array with a simple split

myCustomFieldFromVariable.split(",")

I'm just putting the snippets here to help if someone googles it 

Thanks a lot José !

 

And I wish Atlassian could update the documentation to make it clear 

Like José Nogueira likes this
0 votes
Aron Gombas
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.
March 22, 2022

I haven't tried, but you're doing two things in that expression: splitting and getting the 2nd components plus comparing it to a string literal. If I were you, I'd try if the split-and-get works. If it is, then the problem is with the comparison.

For that, I'd try the Advanced Compare Condition component in the rule.

Thushan Kalhara Withanage March 22, 2022

Hi @Aron Gombas thank you for the reply. Yes, the problem is that the split function does not works as expected. Do you have any suggestions on that, how to split a string value from a custom field in Jira.

Jar Lady
Contributor
April 4, 2024

me too. do you have solution how to retrieve the second element of a field list

Suggest an answer

Log in or Sign up to answer