I'm creating new record using Xrm.WebApi.online.createRecord. I'm adding lookup field value while creating record. See my code below. In the code, new_engagementsector is my lookup field name, 'new_sectors' is the name of lookup entity & 'cr0f8_engagements' is my entity name in which i am adding record.
var entity = {};
entity["new_engagementsector@odata.bind"] = "/new_sectors(97511775-8737-ea11-a813-000d3a0a827e)";
Xrm.WebApi.online.createRecord("cr0f8_engagements", entity).then(
function success(result) {
var newEntityId = result.id;
},
function(error) {
Xrm.Utility.alertDialog(error.message);
});
Its giving below error,
An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'new_engagementsector' which only has property annotations in the payload but no property value was found in the payload.
Is there anything missing in code? please help.