Monday, August 21, 2017

Error while setting a value of Account lookup on Contact in D365 Javascript Web API


You may get an error while setting a value of Account lookup on Contact in D365 Javascript Web API as below:
“An undeclared property ‘customerid’ which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.”

issue arises when lookup attribute of the entity can accept multiple types of entity references.  Examples
1. Customer on Incident
2. Customer on Contact
3. Customer type field on Custom Entity.

We can resolve the issue for setting Customer type field in Javascript D365 Web API by adding a suffix entity name to the schema name of the field.

We can achieve that by adding the suffix entity name to the schema name of the field.

This  code demonstrates how to set Account on Contact.

entity["parentcustomerid_account@odata.bind"] = "/accounts(" + Account_GUID + ")";

This code demonstrates how to set Contact on Contact.

entity["parentcustomerid_contact@odata.bind"] = "/contacts(" + Contact_GUID + ")";

No comments:

Post a Comment

if you have any doubts, please tell me

More Than One Form Was Opened at Once for the Lookup Control

In Dynamics 365 for Finance and Operations, when subscribing to a lookup event to modify an existing lookup on a form control, you must...