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
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
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
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.
Mohamed Amine Mahmoudi
83
Super User 2025 Season 1
Community Member
52
dkrishna
6