Monday, October 26, 2015

How to Get and Set Lookup Value using Javascript in Dynamcis CRM

Code Snippet:

To get a lookup value:


var lookup = new Array();
lookup = Xrm.Page.getAttribute("attributename").getValue();
if (lookup != null) {
    var name = lookup[0].name;
    var id = lookup[0].id;
    var entityType = lookup[0].entityType;
}

To set a lookup value:


var lookup = new Array();
lookup[0] = new Object();
lookup[0].id = recorid;
lookup[0].name = recordname;
lookup[0].entityType = entityname;
Xrm.Page.getAttribute("attributename").setValue(lookup);



Description:


No comments:

Post a Comment