In a multiselect field, how do I use a smart value to test is a value is selected
Asked by Lukasz:

I have a form in my JSM project. The form has a question:
> Question?
>
> \[ \] X
>
> \[ \] Y
>
> \[ \] Z

Now, I want to create an automation that will post a comment that will look differently depending on what options were selected. It would be something like... (pseudocode)
> Hello {{requester.displayName}},
>
> Thanks for raising this issue.
>
> {{selected(Question?, X)}}Since your issue concerns X, we advise you to...{{/}}
>
> {{selected(Question?, Y)}}Since your issue concerns Y, we will...{{/}}
>
> {{selected(Question?, Z)}}Because you mentioned Z, the next steps are...{{/}}

Importantly, any combination of X, Y, Z is valid in the form, and each of the pieces of text should be generated (or not) independently of each other.

I'm trying to find documentation on how to use smart values to see if a particular value in multiselect field is selected, but <https://support.atlassian.com/cloud-automation/docs/examples-of-using-smart-values-with-lists/> is not much help. Best I can think of is to convert all the selected values into a single concatenated string and then try to regex for each specific value with <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--> but that seems really clunky.

Is there a better way?

Thanks!


Answers:
author: Rebekka Heilmann _viadee_
body: Hi [@Lukasz](/t5/user/viewprofilepage/user-id/4268233)

is the answer to the question saved into a Jira Field? If it's only part of a form, you're more or less out of luck or at least have to fiddle with the forms API which isn't that far developed yet.

I would therefore suggest creating a Multiselect List Custom field (if not done yet) so you can easily access the result in an automation rule.

Where do you want the texts populated? You want it posted as a comment?

comments: author: Lukasz
body: Hi [@Rebekka Heilmann _viadee_](/t5/user/viewprofilepage/user-id/5182395)

Thanks for your answer. Yes, the question is saved to a Jira field, and yes, I want them posted as a comment.


author: Rebekka Heilmann _viadee_
body: In that case, you can simply use the issue fields condition and don't need a smart value.

You can check for selected values in Multiselect fields: is one of... equals.... is empty... etc.

You need to create a lookup table where you manage your comment texts. Then create 3 variables for each condition and set a value from the lookup table. You then concat these in the comment: {{varA}} {{varB}} {{varC}}

That might give you some unwanted spaces but not sure if there is a nicer solution to concat Strings over multiple conditions.

*Note: I couldn't test the rule below, as I ran out of rule executions on my test site.*

![Screenshot 2024-04-24 102201.png](https://community.atlassian.com/t5/image/serverpage/image-id/320241i6EA57359790DA74D/image-size/large?v=v2&px=999 "Screenshot 2024-04-24 102201.png")

![Screenshot 2024-04-24 102309.png](https://community.atlassian.com/t5/image/serverpage/image-id/320243i851D8ADF2368FD55/image-size/large?v=v2&px=999 "Screenshot 2024-04-24 102309.png")![Screenshot 2024-04-24 102322.png](https://community.atlassian.com/t5/image/serverpage/image-id/320242iF102FFFE57A0FA02/image-size/large?v=v2&px=999 "Screenshot 2024-04-24 102322.png")


Tags: cloud

jira-service-management

jira-service-management-cloud