Hello User,
Please refer below article which is having updated JS code.
The article which you are referring, having deprecated api's.
Sample Code:
function setLookupField(formContext) {
var lookupValue = [{
id: "00000000-0000-0000-0000-000000000000", // GUID of the record
name: "Record Name", // Display name of the record
entityType: "account" // Logical name of the entity
}];
formContext.getAttribute("your_lookup_field").setValue(lookupValue);
}
function getLookupField(formContext) {
var lookupField = formContext.getAttribute("your_lookup_field").getValue();
if (lookupField) {
console.log("Lookup Name: " + lookupField[0].name);
console.log("Lookup ID: " + lookupField[0].id);
console.log("Lookup Entity Type: " + lookupField[0].entityType);
} else {
console.log("Lookup field is empty.");
}
}
Thank you,
Amit Katariya