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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans