I'm able to go through a single column by initializing a variable as so:
choiceColumns
[
"Column1"
]
Apply To Each
input: choiceColumns
append to another variable (columnValueList) the columns value
*Name: columnValueList
*Value: triggerBody()[items('Apply_to_each')][0]['Value']
So what this does is grabs the value of Column1 and stores it in a variable, my issue is that I have many columns, and I want to loop through all of them and grab all their values and append to same variable.
choiceColumns
[
"Column1",
"Column2",
]
this doesnt work for me.
also, as an aside, why does this code work when the way the brackets are arranged looks wrong?
triggerBody()[variables('myVariable')[variables('loopIndex')]]
also written as:
triggerBody()[variable[variable()]] ? can someone help me understand what this line of code does written in this strange way?
I'm not sure if you're wanting to do this for multiple items (rows) and whether it's from a SharePoint list or not, but that's what I've gone with which should show the main logic.
The list I'm using for this example is:
The full flow is below. I'll go into each of the actions.
Get items retrieves all the items from my list.
Fields is a Compose that contains the list of fields I want to retrieve values from. Note that this would be a list of internal field names. In this example, I just want the values from field_02 and field_03.
Apply to each iterates through each of the items returned.
Select will return the values from each of the fields in your array. The input is your Fields array, and the expression used is:
items('Apply_to_each')?[item()]
Filter array uses the output from Select and removes any blank values (if one of the field values was blank in the list). The expression used is below. Note that the condition uses is not equal to and Choose a value is left as it is.
item()
Join then takes the output from Filter array and joins them by whatever you want. In this example, I'm joining them by a semicolon.
After running the flow, we get the following output for each of the two items (rows) in the list.
the issue with my data is that i need to both loop through xml that looks like this
<field_15>dataIneed</field_15> (field_15 thats the column name of a single line of text column)
and <field_14>{
value:"choice1" (column value i need from field_14 who is a column name as well, but of a choice column, hence the different structure)
}
but because field_14 can be any column name i need some logic to filter which ones i want.
if field_14 choice equals a certain value
i need field_15 single line of text value
also check field_16, and so forth
Hi @dperez13
I have created sample for you to get multiple choice column value in apply to each action.
1. use get items Action to retrieve all the item.
2. After that use one compose action (XML)
xml(json(concat('{"root": { value:', outputs('Get_items')?['body/value'], '}}')))
Expression:
For highlighted text provide correct name according to your actions
3. Then use one apply to each action and iterate on items which return by get items Action.
4. then use one compose action (JSON)
join(xpath(outputs('XML'), concat('//value[ID=', items('Apply_to_each')?['ID'], ']/TestChoice/Value/text()')), ', ')
Expression:
List
-------------------------------------------------------------------------
If I have answered your question, please mark post as Solved.
If you like my response, please give it a Thumbs Up.
Michael E. Gernaey
179
Super User 2025 Season 1
David_MA
161
Super User 2025 Season 1
stampcoin
143