Wednesday, 21 June 2017

{know-how} Set a lookup value on create/update of a record using MSCRM WebApi - An undeclared property Error

Recently faced an error while creating and updating records in CRM using WebAPI. The issue was around setting a lookup value and following is the error message

An undeclared property new_primaryincident 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.

The issue is due to the fact that whenever we set a lookup value we need use schema name and not the logical name. In my case I had to use "new_PrimaryIncident" instead of  "new_primaryincident".

Code snippet:

// code with issue

// code after fix

Hope this helps!

No comments:

Post a Comment

Contact Form


Email *

Message *