cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Mgodby
Post Patron
Post Patron

Is it possible to do an apply to each on a Choice?

Hello. I am wondering if there is a way to apply an apply to each action on a list of choices? I have a choice field with a list of choices and am wondering if there is a way to loop through each choice so I can format it in a way that will work in an adaptive card? 

Is this possible? Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Mgodby,

 

There is a way.  I have just written up a blog post about it.  There is a rest api that you can call to retrieve the choices and then using the select action you can repurpose the data so that you have an array of choices, perfect for an apply to each.

 

Please let me know how you get on.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

View solution in original post

8 REPLIES 8
PrasadAthalye
Community Champion
Community Champion

Are you referring to reading choice selection values that you configured when you create column? 

OR

Data that you selected when you create a new Record\List item?

 

If it is first one, how many values you have? If there are many, best option is to create a new List to maintain them and create a lookup column. Then you can use the list to read the choices.

 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

Thank you. Yes, my scenario is the first one. So you think the best case is just to store those choices in another table/list and just use a lookup field to get them instead? I was thinking of doing that since I can get the apply to each to work on lookups and then format them for an adaptive card just fine.
So is there no way to do an apply to each for the values of a Choice?

@Pstork1 - Do you know any way to read Choice column options in Power Automate? 

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

What specific data source is the choice column in?



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

@Pstork1 - Its a SharePoint List Choice column.

Please Like and Mark this as Answer if it resolves your Issue.

Power Automate Community

I haven't found any way to do that in a flow.  It is possible in Power Apps.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Hi @Mgodby,

 

There is a way.  I have just written up a blog post about it.  There is a rest api that you can call to retrieve the choices and then using the select action you can repurpose the data so that you have an array of choices, perfect for an apply to each.

 

Please let me know how you get on.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

Paulie78
Super User
Super User

Hi @Mgodby ,

 

The method provided by the ever resourceful @DamoBird365 will do the job, but you might want to try this method also, it is slightly easier.

GetPossibleSharePointChoices.png

The code you need in the URI of the HTTP request is:

_api/web/lists/GetByTitle('ChoicesTest')/Fields/getByTitle('Choose Something')

Where ChoicesTest is the list name and Choose Something is the name of the field.

In the compose step the expression is:

outputs('Send_an_HTTP_request_to_SharePoint')?['body']['d']['Choices']['results']

Which will return you a simple JSON array, which looks like:

[
  "Choice 1",
  "Choice 2",
  "Choice 3"
]

Best of luck, let us know how you get on.

 

Blog: tachytelic.net

YouTube: https://www.youtube.com/c/PaulieM/videos

If I answered your question, please accept it as a solution 😘

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (1,576)