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:
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?
@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.
@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.