Announcements
Hi,
when i am trying to insert sales order through console application by calling odata end point (SalesOrderHeaderEntity).
i am facing this error
"insert not allowed for field 'OrderTotalChargesAmount'"
I saw in entity level as this field has allow edit , allow edit on create - no.
How can we resolve this.
Skipping this field in mapentitytodatasource(), initializeEntityDatasource() is the correct way.
Please show some light on this,
Regards,
Have a nice day
Hi Gunjan,
I found solution for this.
I use this piece of code
context.SaveChanges(SaveChangesOptions.PostOnlySetProperties | SaveChangesOptions.BatchWithSingleChangeset);
savechangeoptions.postonlysetproperties - Which will avoid setting null values.
Now that ordertotal amount error is gone now and now i am getting mandatory field errors which i will fill add fields to entity and will try to insert.
Regards,
Hi Gunjan,
Please check this
SalesOrderHeaderV2 soh = new SalesOrderHeaderV2(); DataServiceCollection salesOrderCollection = new DataServiceCollection(context); salesOrderCollection.Add(soh); soh.SalesOrderNumber = salesOrderNumber; // Change number sequence setting in AX to allow user to set values. soh.CurrencyCode = "USD"; soh.InvoiceCustomerAccountNumber = "US-003"; soh.OrderingCustomerAccountNumber = "US-003"; soh.LanguageId = "en-us"; soh.DataAreaId = "USMF"; context.SaveChanges();
Please show light on this
Regards,
Have a nice day.
Hi,
Could you please share the code you are using?
Hi gunjan,
Hope you are fine.
i have tried SalesOrderHeaderV2Entity now i am getting different field
'OrderTotalAmount'
I am not entering any value for this field.
This field is also having allow edit , allow edit on create - no.
Please show some light on this.
Regards,
Have a nice day.
Hi,
What version of D3FO are you on?
In the current version, SalesOrderHeaderEntity is obsolete. You should use SalesOrderHeaderV2Entity instead.
Secondly, are you trying to set this field while inserting into the entity? This belongs to SalesOrderTotals table, which is marked as a ReadOnly data source in the entity. You can read from this table, but can't write into it.
André Arnaud de Cal...
294,060
Super User 2025 Season 1
Martin Dráb
232,858
Most Valuable Professional
nmaenpaa
101,158
Moderator