Hi Dushyant agre,
You will need to use an API such as Xrm.WebApi.retrieveRecord in order to achieve this. Is there a particular reason you do not want to use an API?
The following example demonstrates how to retrieve the contact for an account record with record ID = a8a19cdd-88df-e311-b8e5-6c3be5a8b200. For the related contact record, we are only retrieving the contactid and fullname properties. You can adapt this code to meet your requirement.
Xrm.WebApi.retrieveRecord("account", "a8a19cdd-88df-e311-b8e5-6c3be5a8b200", "?$select=name&$expand=primarycontactid($select=contactid,fullname)").then(
function success(result) {
console.log("Retrieved values: Name: " result.name ", Primary Contact ID: " result.primarycontactid.contactid
", Primary Contact Name: " result.primarycontactid.fullname);
// perform operations on record retrieval
},
function (error) {
console.log(error.message);
// handle error conditions
}
);
The above example displays the following in your console; you might see other values depending on your data:
Retrieved values: Name: Adventure Works, Primary Contact ID: 49a0e5b9-88df-e311-b8e5-6c3be5a8b200, Primary Contact Name: Adrian Dumitrascu