SET VALUES>>
function SetLookupValue(fieldName, id, name, entityType) {
if(fieldName != null) {
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = id;
lookupValue[0].name = name;
lookupValue[0].entityType = entityType;
Xrm.Page.getAttribute(fieldName).setValue(lookupValue);
}
}
// USE
SetLookupValue("new_blogid", "{FD140AAF-4DF4-11DD-BD17-0019B9312238}", "CRM Stuff", "new_blog");
================================================
function SetLookupValue(fieldName, id, name, entityType) {
if(fieldName != null) {
var lookupValue = new Array();
lookupValue[0] = new Object();
lookupValue[0].id = id;
lookupValue[0].name = name;
lookupValue[0].entityType = entityType;
Xrm.Page.getAttribute(fieldName).setValue(lookupValue);
}
}
// USE
SetLookupValue("new_blogid", "{FD140AAF-4DF4-11DD-BD17-0019B9312238}", "CRM Stuff", "new_blog");
================================================
GET VALUES>>
var lookUpObjectValue = Xrm.Page.getAttribute("yourlookupattributename");
if (lookUpObjectValue != null)
{
var lookuptextvalue = lookUpObjectValue[0].name;
var lookupid = lookUpObjectValue[0].id;
}