[Resolved] – EntityState must be set to null, Created (for Create message) or Changed (for Update message)

Recently I was facing an issue with Update of a record in the Plugin. The error message was as ‘EntityState must be set to null, Created (for Create message) or Changed (for Update message)’.

The plugin was written on Post-Operation of Create action.

After looking for the resolution for the issue, I came across a solution posted online, which I am not sure, is supported, but worked for me.

Before calling the _service.Update(Entity), You need to change the state of entity as below:

recordToUpdate.EntityState = EntityState.Changed;

Hope this helps.

Also there is another approach to resolve this:

Instead of using

context.Update(object),

Use:

context.UpdateObject(object)

Reference:

http://stackoverflow.com/questions/6187978/entitystate-must-be-set-to-null-created-for-create-message-or-changed-for-u

The request channel timed out while waiting for a reply after 00:01:59.9430000. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout. dynamics crm

Recently I was facing another issue with BulkInsert from my console to D365, using ExecuteMultiple. As per the documentation on MSDN, ExecuteMultiple has run-time limitation to have maximum batch-size of 1000.

Link: https://msdn.microsoft.com/en-in/library/jj863631.aspx

However, I was facing time-out issue for 999.

Turns out, I need to specify a smaller batch size to overcome this issue.

Specifying batch size as 500 was working fine for me.