Branch over Smart Value List only executes once
Asked by Rebekka Heilmann _viadee_:

I want to branch over a list of values, in the specific case it is the "Affected Services" field (JSM specific).

For my test, the field contains 3 Values and the Log Action returns: "ServiceA, ServiceB, ServiceC". However, the branch only executes once and the Variable contains the whole list rather than only one value at a time.

My understanding was, that the Branch rule would be like a for each. So for every value in a field, I can execute actions. Therefore, i would have expected the Variable to return "ServiceA" for the first iteration, "ServiceB" for the 2nd and so forth. That doesn't seem to be the case.

Question: Is is a bug or a feature? What am I missing here?

![Screenshot 2024-01-15 164803.png](/t5/image/serverpage/image-id/300592i5C5B464DCFC9ACAD/image-size/large?v=v2&px=999 "Screenshot 2024-01-15 164803.png")


Answers:
author: Bill Sheboy
body: Hi [@Rebekka Heilmann _viadee_](/t5/user/viewprofilepage/user-id/5182395)

What is the type of your custom field: text, multiple select, something else?

Some field types need to use the split() function to turn them into a list for processing by the branch. For example:

* a text field containing: A,B,C
* would need to be split with this to be used: {{issue.myCustomField.split(",")}}

Kind regards,  
Bill

comments: author: Rebekka Heilmann _viadee_
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

It's not a custom field. Affected Services is a System field that is connected to the "Services" Feature from JSM.

![Screenshot 2024-01-15 171115.png](https://community.atlassian.com/t5/image/serverpage/image-id/300595iF6AD2A7451A0C209/image-size/large?v=v2&px=999 "Screenshot 2024-01-15 171115.png")

If I change it to {{issue.Affected services.split(",")}} it doesn't return anything at all.


author: Bill Sheboy
body: That is curious that the type is unknown. I am not using JSM, and so I wonder if this is a dynamic field, calculated just-in-time for usage, which then prevents use in the branch.

The way to check this (and solve your scenario need) is this:

* using the Create Variable action, save the field value, which will make it text
  * variable name: varAffectedServices
  * Smart value: {{issue.Affected services}}
* write that to the audit log to confirm it contains what you expect, and adjusting the delimiter for the split() as needed
* now branch over that value like this:
  * {{varAffectedServices.split(",")}}


author: Rebekka Heilmann _viadee_
body: It worked now.

I used {{issue.Affected Services.name.split(",")}}

No need for a variable - that was a Layer 8 problem ;) - I didn't know that Automation appends Log messages into one output if there is no action in between.

Now I just need to figure out how to copy the the corresponding Affected Service to each Sub-Task ;)


author: Bill Sheboy
body: Well done!

They were objects, similar to iterating over users. Once you have the object, the different attributes need to be accessed.

This how-to article can help when using smart values like this, as it shows the structure and smart values in the issue: <https://support.atlassian.com/cloud-automation/docs/find-the-smart-value-for-a-field/>


Tags: cloud

jira-service-management