Using String Manipulation functions on Select List Fields - Jira Automation

Amanda McGivern September 10, 2020

I'm trying to set a custom field value based on the value of two other fields. I only need the first character of each field and then I will concatenate them to come up with the rank. All of the fields are single-select custom fields. I currently use a hard-coded list of conditionals but I've hit the component limit.

For example: the severity is "2 -  High" and the classification is "3 - Medium" so I want to set the rank to "2 - 3". 

This seems like it should be possible using the smart value string functions in Jira automation. I think that the charAt function is exactly what I'm looking for but I can having some issues getting it to work. 

Here are some of the combinations I've tried but, they all return blank values for the example I've provided above.

{{issue.customfield_10055}} // This returns the expected value "2 - High"

// The rest of these are blank...
{{issue.customfield_10055.charAt(1)}}

{{issue.customfield_10055.asJsonString}}

{{issue.customfield_10055.asJsonString.charAt(1)}}

{{issue.customfield_10055.left(1)}}

{{issue.customfield_10055.abbreviate(1)}}

{{issue.customfield_10055.value.charAt(1)}}

Does anyone know if it is possible to use these functions on single select fields? If not, can you think of any other ways to accomplish my goal?

Thanks in advance!

1 answer

1 accepted

3 votes
Answer accepted
Sam Harding
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 14, 2020

Hi Amanda,

It is possible to do what you are wanting using single select fields, and your current solution is very close to working. To get the string value of a select field, you need to use:

{{issue.customfield_10055.getValue.charAt(0)}}

The `getValue` is required to get the select's string value, and then the string operations will work as you are expecting. Please note, the index to use for the `charAt` would be 0 in your use case, as opposed to 1, due to the string value indices starting at 0.

Let us know if that works for you, hope this helps.

Cheers

Amanda McGivern September 15, 2020

Hi Sam,

That worked great. Thank you for your help.  For my future reference, where did you find this information? 

Sam Harding
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 15, 2020

Hi Amanda,

Glad that it worked for you. Unfortunately, I could not find specific documentation discussing this functionality, as it is not a common use case that we have come across, needing to perform string operations on a select field value. To work this out I looked directly at the source code and performed some tests of my own to verify. I have raised this concern about lack of documentation on this feature within the team, and hopefully this will be clearer for our users in the near future.

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