Monday, February 6, 2012

MS CRM 2011: How to read the value from Lookup?

Many times we required to read lookup value and Guid of Lookup for this use the following line of code:

function movecase() {

var lookupObject = Xrm.Page.getAttribute("LookupFieldId");

if (lookupObject != null)
{

var lookUpObjectValue = lookupObject.getValue();

if ((lookUpObjectValue != null))
{

var lookuptextvalue = lookUpObjectValue[0].name;
alert(lookuptextvalue);
var lookupid = lookUpObjectValue[0].id;
alert(lookupid);
}

}

No comments: