Notifications
Announcements
No record found.
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
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.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
SA-08121319-0 4
Calum MacFarlane 4
Alex Fun Wei Jie 2