Sorting repeating group by option set

I have a repeating group containing Artifacts. They have, among other fields, Name and Priority. Name is a text field. Priority is an option set. I select Artifacts on several criteria and sort them prior to display. I can sort the repeating group by Name but Priority isn’t on the list of sorting options in the “Search for” form. It only lists the text fields. How do I sort the Artifacts in the repeating group by Priority?

And, a further question:
The Priority option set has three values: Low/Medium/High. A drop down shows them in that logical order (which is how I entered them). But, if I sort them alphabetically, they will be in the order: High/Low/Medium. I want them sorted in the logical order rather than alphabetical order. How would I do that?

Thanks for any help you can provide.

To answer the second part of your question, one way to do it is to add an attribute to the option set, called something like rank/priority/order etc. of type 'Number.

So for example, High might be 1, medium 2, and low 3 (or the other way round - whichever is most logical to you).

Then you can sort the options in the dropdown by that attribute.

n.b. Although, specifically in the case of Option Set options, by default (if you don’t add any additional sorting) the options will be displayed in the order they appear on the option set tab of your app data in the editor, and you can change this order to suit by using the ‘Move Up’ and ‘Move Down’ buttons next to each option.

So it’s probably simpler to just use that, and set the order there.

As for your first question, having just looked at it there doesn’t seem to be any obvious way to do it (which is strange). I might be overlooking something simple, so if I work it out I’ll get back to you, but as far as I can see right now there’s no way to sort by an option set field, unfortunately.

The only workaround I can think of at the moment is having an additional field (number) on the Artefact datatype just for sorting, then set that using the priority option set.

1 Like

Any progress with this? Any workaround?

@alan5
As far as I know - there isn’t a native way to sort a data type (thing) by something in one of it’s option set fields. AKA - Your artifact has a Option Set Field, called Priority, and Priority has a numerical value you want to sort by (your situation). There is a large thread about this stuff here as well.

You can always modify your workflows to copy this numeric over but it may get hard to manage depending on your data structure and how it’s interacted with - however…

One thing you can do however that I believe gets you want you want is a nested repeating group. You can sort Option Sets by a Attribute of that option set (Priority as Numeric in the photo above). So what you want to do is put a repeating group of type Priority - sorted by that numeric, and then inside that repeating group put a search for the artifact with a constraint of the priority being the parent priority.

You can get creative with the filtering, sorting via ascending/descending, or other stuff with either states or dropdowns or whatever, and put more constraints on the inner search for the artifacts.

See Version Test and Dev Mode

2 Likes

Bump. Any solution to this obviously important issue? Inability to sort an RG based on one or more option set defined fields is crippling in many use cases.

4 Likes

No changes as far as I can tell but another workaround is to merge lists that are searched for and filtered based on priority. Not scalable, but works.

Version Test - at the bottom

See above.