web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

insert not allowed for field 'OrderTotalChargesAmount' when creating sales order through odata

(0) ShareShare
ReportReport
Posted on by 2,426

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

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    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.

  • AX 2012 r3 Profile Picture
    2,426 on at

    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.

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi,

    Could you please share the code you are using?

  • AX 2012 r3 Profile Picture
    2,426 on at

    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.

  • AX 2012 r3 Profile Picture
    2,426 on at

    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,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 733

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 461 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 278 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans