Solved

SharePoint Query list action does not sort?

  • 18 November 2020
  • 4 replies
  • 32 views

Userlevel 3
Badge +9

How to obtain a sorted item list from a SharePoint Query List action?

I have certain recipes and each recipe has a priority (integer value). I simply need to have the recipe with the highest priority on top when I start looping through the result set using a For Each action:

9487i79BA504EEB7BC07C.png

I expected the sort option in the Query List action. But not. It is also not in the For Each action. And the Sort a Collection action will not sort a collection of items. Sorting also doesn't take place in defining the data connection so I am running out of options.

What did I miss?

icon

Best answer by WouterT 30 November 2021, 08:10

View original

4 replies

Userlevel 5
Badge +13

@WouterT What is the range of priority you are dealing with,  i'm thinking you might need to use logic inside of a for each to build out a collection that has the item ID's in the order you would like.

Userlevel 3
Badge +9

@leighburke Thanks for the reply!


 


This list of recipes will grow until probably 40 or 50 items. It has been decades ago that I programmed a manual bubble-sort algorithm 🙂 Not looking forward to that.


 


I need to loop through the recipes from priority high to low and as soon as I find a recipe that fits the requirements (=max. 4 parameters) I quit the For Each and pass the ID on to the next part of the workflow. There might be multiple recipes fitting the requirement parameters so I need to honor the highest priority which sets the rule for which recipe prevails over another.


 


I have created a funny workaround now using a NW365 site workflow that creates every day a new list of RecipeID's in the right order in a separate list.



The For Each in NWC goes on this list first.


A bit ugly but works for now.


I really miss the sorting in the Query List action. I have used it so often on NW4SP and NW365.


 

Userlevel 5
Badge +13

@WouterT Glad you got something working. I will certainly raise the adding sorting options.

Userlevel 3
Badge +9
And tadaa... exactly one year later there it is: the ability to sort query results! Saves a lot of extra work and headaches. The workaround never worked properly.

Reply