RE: Auto Populate lookup field
Bipin Kumar
i downloaded Dataverse REST on my instance , and i try to build code with your advise
but it still not worked. . .
function LookupValue(executionContext){
var formContext = executionContext.getFormContext();
var lookupvalue1= formContext.getAttribute("cr337_phonenum_01");
if (lookupvalue1 != null) {
var lookup = lookupvalue1.getValue();
var id = lookup[0].id;
if ((lookup != null)) {
Xrm.WebApi.retrieveRecord("cr337_nok_phonenum_01", id, "?$select=cr337_patient_name_01").then(
function success(results) {
{
var lookup = []; // // Creating a new lookup Array
lookup[0] = {}; // new Object
lookup[0].id = id; // GUID of the lookup id
lookup[0].name = results.cr337_patient_name_01; // Name of the lookup
lookup[0].entityType = "cr337_nok_phonenum_01"; // Entity Type of the lookup entity
formContext.getAttribute("cr337_contact_01").setValue(lookup);
}
});
}
}
}