Using list.get(x) with the value of x from another smart variable
Asked by Ken Young:

I am trying to use a smart variable in the following way:

```
{{priorities.split(":").get(ppValue.asNumber)}}
```

priorities are created as a list proceeding this action, are are "Highest:High:Medium:Low:Lowest" . ppValue is set to 1 earlier in the automation.

When I run, there is no value returned.

*** ** * ** ***

When I reformat as the following:

```
{{priorities.split(":").get(1)}}
```

it returns "High" as expected.

Any thoughts on how to format this so the dynamic value can be passed in?

Thank you


Answers:
author: Ken Young
body: [@Bill Sheboy](https://community.atlassian.com/t5/user/viewprofilepage/user-id/1685313)

I was unable to get the split to return a result.

My final solution (included in a Create Variable smart action) was

```
{{#if(equals(ppValue,"1"))}}Highest{{/}}{{#if(equals(ppValue,"2"))}}High{{/}}{{#if(equals(ppValue,"3"))}}Medium{{/}}{{#if(equals(ppValue,"4"))}}Low{{/}}{{#if(equals(ppValue,"5"))}}Lowest{{/}}
```

Thanks for the feedback and help

comments: author: Bill Sheboy
body: I am glad you got it to work, even if the get() after the split did not work.

I had an error in my post, as after split() the list is 0-based, not 1-based, so I will update that for anyone else who reads this.


author: Bill Sheboy
body: Hi [@Ken Young](/t5/user/viewprofilepage/user-id/4596309)

In my experience, several of the functions in automation rules cannot take a created variable or smart value as a parameter. I recall hitting this exact same symptom trying to solve another problem and found get() had this behavior/limitation. Same symptom with smart value, list filtering.

The only work-around I found was to use a series of adjacent, [conditional logic expressions](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-conditional-logic/)...with the intent that one-and-only-one would evaluate to true. This seemed to break the chain of smart value parsing which caused a null somewhere.

Perhaps try this:

{{#if(equals(ppValue,1)}}{{priorities.split(":").get(1)}}{{/}}{{#if(equals(ppValue,2)}}{{priorities.split(":").get(2)}}{{/}}{{#if(equals(ppValue,3)}}{{priorities.split(":").get(3)}}{{/}}{{#if(equals(ppValue,4)}}{{priorities.split(":").get(4)}}{{/}}{{#if(equals(ppValue,5)}}{{priorities.split(":").get(5)}}{{/}}

Kind regards,  
Bill

comments: author: Ken Young
body: Thank you [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) for the suggestion. I tried the code in a create variable action, but unfortunately is set a null action. I will, however, try it in "additional fields" when I am trying to create or updated an issue to see if I get a different result.

If it worked in the create variable, this could be a really powerful way to extend automation.


author: Bill Sheboy
body: Ooops, my bad; missing closing parentheses as I wrote that from memory. Here is the fixed one:

{{#if(equals(ppValue,1))}}{{priorities.split(":").get(0)}}{{/}}{{#if(equals(ppValue,2))}}{{priorities.split(":").get(1)}}{{/}}{{#if(equals(ppValue,3))}}{{priorities.split(":").get(2)}}{{/}}{{#if(equals(ppValue,4))}}{{priorities.split(":").get(3)}}{{/}}{{#if(equals(ppValue,5))}}{{priorities.split(":").get(4)}}{{/}}

UPDATED: after the split() the list is 0-based and not 1-based.


author: Ken Young
body: Thanks for the feedback and help


author: Curt Holley
body: Hi [@Ken Young](/t5/user/viewprofilepage/user-id/4596309)   
What is it you are trying to achieve with this rule?

Perhaps if we could see all of the workings it would make it easier for us to assist.

comments: author: Ken Young
body: Hi [@Curt Holley](/t5/user/viewprofilepage/user-id/3527535) . I have an external system that is passing in information via email (formatted subject line) to Jira. Priority can be P1, P2, P3, P4, P5, I am trying to convert to Jira's priorities aka: "Highest:High:Medium:Low:Lowest". In this manner, I can set the priority of the created ticket to the correct priority using the "additional fields" in the edit issue action.

My other option is possibly to us the ID, but I am trying to determine if this mapping could be done,

Thx