Dynamics AX 365 insert not allowed for field ‘XXXX'”,”type”:”System.InvalidOperationException”

I was working on creating the new Data entity related to Case Details on Dynamics ax 365, The creation went well and simple. when i tried to consume the new Data entity from odata client using c#, i got this exception.

An error occurred while processing this request.{
“code”:””,”message”:”An error has occurred.”,”innererror”:{
“message”:”insert not allowed for field ‘CaseId'”,”type”:”System.InvalidOp
erationException”,”stacktrace”:” at Microsoft.Dynamics.Platform.Integration.Se
rvices.OData.Update.UpdateProcessor.CreateEntity_Save(ChangeOperationContext con
text, ChangeInfo changeInfo)\r\n at Microsoft.Dynamics.Platform.Integration.Se
rvices.OData.Update.ChangeInfo.ExecuteActionsInCompanyContext(IEnumerable`1 acti
onList, ChangeOperationContext operationContext)\r\n at Microsoft.Dynamics.Pla
t operationContext)\r\n at Microsoft.Dynamics.Platform.Integration.Services.OD
ata.Update.UpdateManager.SaveChanges()\r\n at Microsoft.Dynamics.Platform.Inte

This error is related to CaseId field on Case Details, after enough investigation i found that validatefield method from corresponding table is being fired and not allowing manual insertion on CaseId field. As this field is Number sequence bound. But our requirement was to create the case using custom value provided from Odata client using c#.

After enough research i got the clue to skip the table level validation from data entity. So i have decided to modify the data entity and override following methods and skip the table level validation for the CaseId field.


Amir- Happy daxing 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: