It’s often required to get the value of primary entity from its related entity.
Let’s take two entity Office and Employee. There is a 1:N relationship between Office and Employee,where Office is the primary entity and Employee is the secondary entity.
Now following piece of “Java Scipt” code help you to retrive the Guid,Name and Type of Office Entity from Employee Entity.
*Note:Write it onLoad() or onSave () event of the form.
var lookupItem = new Array;
// This gets the lookup for the attribute new_doctor_pateintsid on the Pateint form.
lookupItem = crmForm.all.new_doctor_pateintsid.DataValue;
// If there is data in the field, show it in a series of alerts.
if (lookupItem != null)
// The text value of the lookup.
// The GUID of the lookup.
// The entity type name.