Hi,
Here is the JavaScript for getting/setting Look Up details in CRM 2011/2013/2015.
var varEntityName, varEntityId, varEntityType, varLookupFieldObject;
var varLookupFieldObject = Xrm.Page.data.entity.attributes.get("parentaccountid");
// Get Parent Account Details.
if (varLookupFieldObject.getValue() != null) {
varEntityId = varLookupFieldObject.getValue()[0].id;
varEntityType = varLookupFieldObject.getValue()[0].entityType;
varEntityName = varLookupFieldObject.getValue()[0].name;
setLookUpValue(varEntityId, varEntityName, varEntityType)
}
}
// Set the Look Up.
function setLookUpValue(accountId, accountName, entityLogicalName) {
Xrm.Page.getAttribute("new_populateparentaccount").setValue([{
id: accountId,
name: accountName,
entityType: entityLogicalName
}]);
}
Hope this helps.
--
Happy CRM'ing
Gopinath.
Here is the JavaScript for getting/setting Look Up details in CRM 2011/2013/2015.
//
Get Look Up Details.
function getLookUp() {var varEntityName, varEntityId, varEntityType, varLookupFieldObject;
var varLookupFieldObject = Xrm.Page.data.entity.attributes.get("parentaccountid");
// Get Parent Account Details.
if (varLookupFieldObject.getValue() != null) {
varEntityId = varLookupFieldObject.getValue()[0].id;
varEntityType = varLookupFieldObject.getValue()[0].entityType;
varEntityName = varLookupFieldObject.getValue()[0].name;
setLookUpValue(varEntityId, varEntityName, varEntityType)
}
}
// Set the Look Up.
function setLookUpValue(accountId, accountName, entityLogicalName) {
Xrm.Page.getAttribute("new_populateparentaccount").setValue([{
id: accountId,
name: accountName,
entityType: entityLogicalName
}]);
}
Hope this helps.
--
Happy CRM'ing
Gopinath.
No comments:
Post a Comment