Monday, 18 May 2015

Get and Set Look Up Details in CRM 2011/2013/2015.


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 ="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) {
        id: accountId,
        name: accountName,
        entityType: entityLogicalName

Hope this helps.

Happy CRM'ing

No comments:

Post a Comment