Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Sort columns on subgrid/views

Posted on by 40

Hi, when sorting a subgrid ID by ascending then Name by ascending, I get this column:

+----------+-----------+
| Name       | ID           |
+----------+-----------+
| R1            | ---           |
+----------+--------- --+
| R2            | ---           |
+----------+-----------+
| R3            | ---           |
+----------+-----------+
| R4            | 1             |
+----------+-----------+
| R5            | 2             |
+----------+-----------+
| R6            | 3             |
+----------+-----------+

I want to display on CRM this view instead:

+----------+-----------+
Name       | ID           |
+----------+-----------+
| R4            | 1             |
+----------+-----------+
| R5            | 2             |
+----------+-----------+
| R6            | 3             |
+----------+-----------+
| R1            | ---           |
+----------+-----------+
| R2            | ---           |
+----------+-----------+
| R3            | ---           |
+----------+-----------+

Is there any way to achieve this?

Thank you in advance

  • Suggested answer
    LuHao Profile Picture
    LuHao 40,872 on at
    RE: Sort columns on subgrid/views

    Hi Jerome,

    When the records of the view are sorted by a column, the null value is always the smallest, that is, in ascending order, then the null value is always the first. This is by design and cannot be changed.

    So to achieve this requirement, we have to fill the null value with 0. However, the value of the ID field is unique and cannot be repeated.

    For this, we also need to create a custom field and use it to replace the ID field sorting. The value of this custom field is the same as the ID, the only difference is that it uses 0 instead of null. The calculated field can meet this requirement.

    Here, I use the Account entity as an example.

    Account has the Account Number field, I created a calculated field exactly like it.

    pastedimage1607668887345v2.png

    pastedimage1607668956326v3.png

    Then, add the new field as a column to the view, and sort the view in ascending order by the new field.

  • Jerome Vicente Profile Picture
    Jerome Vicente 40 on at
    RE: Sort columns on subgrid/views

    Hi Adrian,

    Thank you for the answer but unfortunately, all records must be displayed as required.

    Thanks,

    Jerome

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 21,009 Super User 2024 Season 2 on at
    RE: Sort columns on subgrid/views

    Hi Jerome Vicente,

    There is no way to change the sort order so that it displays as desired. However, you can modify the filter criteria of the view to remove records with empty ID values.

    +----------+-----------+
    Name       | ID           |
    +----------+-----------+
    | R4            | 1             |
    +----------+-----------+
    | R5            | 2             |
    +----------+-----------+
    | R6            | 3             |
    +----------+-----------+

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Sort columns on subgrid/views

    I believe that when you are sorting id ascending or any number field blanks will appear first followed by fields with information entered.

  • Jerome Vicente Profile Picture
    Jerome Vicente 40 on at
    RE: Sort columns on subgrid

    Hi Andrew,

    That is exactly what I did and both are in ascending order.

    Thanks,

    Jerome

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: Sort columns on subgrid

    Hello,

    Set Sorting on the view by ID and then by Name. Do you have any issues with it?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans