web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

CRM how to sort records based on owner name

(0) ShareShare
ReportReport
Posted on by 6

Hello all experts ,

i need to sort the records based on owner name in an ascending order using javascript .

it will be great if someone can help me in this please.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Kokulan Profile Picture
    18,054 on at

    Hi

    if  you code has list or arrays of records, you can define a function to sort, in the function you can define which prop you want to sort. As long as you use the Owner name to sort, it should work fine

    stackoverflow.com/.../sort-array-of-objects-by-string-property-value

    How you are retrieving the data, is it web api or other means? you should be able to sort in your query itself, you do not need to do this in javascript unless you have a specific requirement to do so.

  • Suggested answer
    Dynamics365 Rocker Profile Picture
    7,755 on at

    In Java Script you have to write below code to get owner name:

    if (Xrm.Page.data.entity.attributes.get("ownerid").getValue() != null) {

              var id= Xrm.Page.data.entity.attributes.get("ownerid").getValue()[0].id;

              var name= Xrm.Page.data.entity.attributes.get("ownerid").getValue()[0].name;

              var entityType= Xrm.Page.data.entity.attributes.get("ownerid").getValue()[0].entityType;

          }

    Collect name in an array. Then follow below link to sort name:

    stackoverflow.com/.../sort-array-by-firstname-alphabetically-in-javascript

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans