I am setting two lookup fields (Contact and Account entity) while creating a custom entity record.
Once the recorded is created I can see Contact lookup is set on the form but not Account.
The Account lookup I am trying to link on custom entity record is related to Contact.
I am using schema names for this purpose and have also tried to create the custom entity record first and then update this with Account record later but it wouldn't have it.
Here is the code:
try
{
//create CR object
var Obj= new Object();
Obj.name = "ABC";
Obj.changedescription = "Test Description";
Obj["abc_Account@odata.bind"] = "/accounts("+ accountId +")"; //Doesn't work and no error
Obj["abc_Contact@odata.bind"] = "/contacts("+ contactId +")"; //Works
Xrm.WebApi.createRecord("abc_entity", Obj).then(function (result) {
//get the guid of created record
var recordId = result.id;
//below code is used to open the created record
var windowOptions = {
openInNewWindow: false
};
//check if XRM.Utility is not null
if (Xrm.Utility != null) {
//open the entity record
Xrm.Utility.openEntityForm("abc_entity", recordId, null, windowOptions);
}
},
function (error) {
Xrm.Utility.alertDialog(error.message);
});
} catch (e) {
Xrm.Utility.alertDialog(e.message);
}
Any suggestions would be welcome.
Thanks