Tuesday, 6 February 2018

How to Get and Set a Lookup Field Using JavaScript in Dynamics 365

How to Get and Set a Lookup Field Using JavaScript in Dynamics 365

Description:

In this example we explain that how to get and set a Lookup field using JavaScript in Dynamic CRM.or how to update the Lookup Value using JavaScript in Dynamic 365.or how to set Lookup field value in Dynamic CRM using JavaScript. Or JavaScript to select a value in Lookup filed in Dynamic CRM.

So here we demonstrate that how to set Lookup Details in Dynamic 365 using JavaScript. Below is the JavaScript code to Get or Set the Lookup field text/value in Dynamic CRM.
Code:

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;

       if (lookupValue[0].id != null)

{

           Xrm.Page.getAttribute(fieldName).setValue(lookupValue);

       }

   }

}


0 comments:

Post a Comment