web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Problems with a sort f...
Power Automate
Suggested Answer

Problems with a sort for Microsoft Lists in Power Automate

(0) ShareShare
ReportReport
Posted on by
Our business is repairing and building truck tanks. I have a scheduler pilot I built in Microsoft Lists. We have techs assigned to jobs that our customers bring in. The repairs are assigned to bay locations, thirty one in all. In Lists we created a hidden column called location sort and a column called location for the bay assignments. I was advised to sort by the location sort which is a hidden column created in the test pilot. Here's the additional detail. We want to be able to sort in ascending order by the location column even though the sort is accomplished in the hidden Location sort column. Further, we want to be able to change the location by tech from the drop down column choices in the location column or by clicking on the bay number in grid edit and picking a different bay. Once the choices are made, the location column would automatically resort in ascending order This functionality is important because these assignments change daily.
 
I used Chat GPT to help me create the workflow.  I have many hours trying to make this work but have been unsuccessful getting the flow to run without errors.  Chat GPT has given me endless loops that don't work to resolve the issues.  Below I've attached screen shots of the errors and the flow diagram as a starting point.  I'd appreciate any input that you could give.  At this point I'm not sure this is even possible.  From the onset, it would seem that the function is fairly straightforward.
 
I'd appreciate hearing back once you have reviewed this.
 
 
Errors:
 
Action 'For_each' failed: The execution of template action 'For_each' failed: the result of the evaluation of 'foreach' expression '@triggerOutputs()?['body/value']' is of type 'Null'. The result must be a valid array.
 
Your flow was saved, but with a warning: Your flow may have a circular loop Actions in this flow may result in an infinite trigger loop. Please ensure you add appropriate conditional checks to prevent this flow from triggering itself.
 
 
 
Flow Diagram:
 
 
 
 
I have the same question (0)
  • Suggested answer
    David_MA Profile Picture
    14,614 Super User 2026 Season 1 on at
    Based on what I see of your flow, I don't see why you need the apply to each action. What data is the apply to each using as it must be an array? Your trigger is when an item is created or modified, so that returns an object rather than an array. Can you also explain what the sorting in your view has to do with what you are doing in the workflow?
     
    I see you also have an update item action in the flow. What did you do to prevent the flow from triggering itself when you update the item? Note the warning about this in the screen shot you shared. If you don't know why this is important to address, you may want to read this: How to avoid infinite trigger loop in Power Automate
  • Suggested answer
    David_MA Profile Picture
    14,614 Super User 2026 Season 1 on at
    For your list sorting, I would do this:
    1. Create a separate list on your SharePoint site with the locations.
    2. In that list, add a number column named sort.
    3. Add this list as a lookup in your Test Sort Pilot List Network.
    4. When you add it as a lookup, be sure to check the sort field.
    5. Then in your view, just sort by the Sort field from the list that contains the locations.
    This is a list I use to demonstrate how to use another list as a drop-down:
    This is a SharePoint list that use the above as a drop-down:
    And this is how you can use the sort value to automatically sort the list in the view:
    If this is all you were trying to achieve, no workflow required.
     
    Note. this shows how the lookup list is added to your list show additional fields:

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 801

#2
Valantis Profile Picture

Valantis 602

#3
Haque Profile Picture

Haque 581

Last 30 days Overall leaderboard