
Hi All,
I have created dropdown field in Canvas app and connected it with 'Design Project Task' Entity which is having option set named as 'Task Status'.
I used following formula in item of Dropdown I created in Canvas App:
Sort(Distinct('Design Project Tasks', 'Task Status'), Ascending)
Now, it is showing me Distinct Option Set list. But not sorting this list.
1. I Checked field option values in solution. They are in sequence.
2. I tried SortByColumns formula but it is not working.
It looks something like this:
Have anyone worked on same issue?
It will be really helpful.
Thanks,
Mayur
Currently, there seems to be no way to sort distinct options of an option set field for a drop-down control. However, you can use the workaround given below to achieve this requirement.
We will add a column in the collection which will store the textual value of the required option set. After this, we can sort this collection based on the textual value column we have created. In the end, as the last step, we can use this collection to get the distinct values from the collection.
Following is the working example for Ownership (OOB option set field) of Accounts Entity-
Distinct(SortByColumns(AddColumns(Accounts,"ownershipcolumn",Switch(Ownership,'Ownership (Accounts)'.Other,"Other",'Ownership (Accounts)'.Private,"Private",'Ownership (Accounts)'.Public,"Public",'Ownership (Accounts)'.Subsidiary,"Subsidiary")),"ownershipcolumn",Ascending).ownershipcolumn,ownershipcolumn);
Hope this helps.
Thanks!