(Canvas App) Is there a way to sort a collection while maintaining the first item at the top of the list? I have a list of users in the collection but manipulated the collection so that "Sort a User" appears at the top. Is there a way to sort the collection and keep "Sort a User" at the top?
I am building a canvas app and I have a drop down that is populated from a collection which is populated from a sharepoint list of the user names. I have manipulated my collection so that "Select a User" appears first in the list. The screen's OnVisible property is set with the following code which populates a collection from a sharepoint list of users.
// Retrieve ALL users that have been assigned to ANY deal
ClearCollect( collUsersAssigned, 'Assigned-Users' );
// Create new collection from selected Deal ID
ClearCollect( collUsersAssignedSelectedID, Filter( collUsersAssigned, Deal_x002d_Request_x002d_ID = galleryLHAssignResources.Selected.'DI-ID' ) );
Next I add the following code so that "Select a User" appears first in the drop down.
// Use a collection to pre-populate User dropdown with a default 'Select a User' option
ClearCollect( myDropdownOptionsUsers, { 'Full-Name': "Select a User"} );
Collect( myDropdownOptionsUsers, 'Available-Resources'.'Full-Name' );
The first item in the drop down menu is always Select a User. I can successfully sort the list items in the drop down using the code below.
Sort( myDropdownOptionsUsers.'Full-Name', 'Full-Name', Ascending )
Unfortunately it also sorts 'Select a User' into the list alphabetically but I need it to remain the first item in the drop down. Is there a way to sort the collection and keep "Sort a User" at the top?