I have a problem with sorting lines in a Grid on a form in D365FO.
The form is not a standard form but one made custom for our solution.
And the problem is that since we need to sort on a field in the Grid that is a Reference Group field, and because of that it was not possible to sort on the data source.
But we found that it was possible for the user to sort on that field in the client by choosing "Sort A - Z", and from that we found that from code we could call the .Sort method on the field with parameters SortOrder::Ascending
But it was not really clear where the best place was to call the .Sort method, so to start with it was placed in the task method on the form that was already used, and that did seem to work.
But if the user then edits some data in the form and press the save button, then the Sorting seems to go back to the old sorting.
So our problem is where should we place the call to the .Sort method to make sure it works?