Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

Auto-remove OData entity if error encountered

(0) ShareShare
ReportReport
Posted on by 101

Hello, I have noticed that when I run into any errors when I POST OData entities (e.g. VendInvoiceJournalHeaders) they still remain in the system, and I have to either remove them manually or have a routine in my code to remove them.

Is it possible to have them be auto-removed if an error was encountered so I don't have to handle it myself?  

  • Suggested answer
    Anton Venter Profile Picture
    Anton Venter 19,493 Super User 2025 Season 1 on at
    RE: Auto-remove OData entity if error encountered

    When data is entered into the system via a data entity, not all data fields are validated and checked in the same way as manually entering the same data in the user interface. The user interface will not allow an invalid field to be selected, or entered, where as a data entity in theory might allow this, depending on the specific data entity of course.

    When manually entering data in the system, the user interface makes many calls to all the validation methods on the tables and in code, depending of the form of course.

    In your invoice scenario, the data is entered via a data entity and not fully validated, but the system is however going to validate the data when posting the invoice.

  • tl2022 Profile Picture
    tl2022 101 on at
    RE: Auto-remove OData entity if error encountered

    Hello, so here is an example of what we are very likely to run into. We post to VendInvoiceJournalLines entity with the invoice information, but the user has mistakenly entered an offset account that does not exist in the system. The POST request comes back with an expected error (e.g. "message":"Write failed for table row of type 'VendInvoiceJournalLineEntity'. Infolog: Error: The MainAccount 12345 for LedgerChartOfAccounts STORE does not exist.; Error: Error found when validating record..",...), but if I go to the vendor invoice journal in the UI, I see the line was still submitted, albeit with alot of missing information. I don't know why this happens instead of the system just not writing a line.

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,074 Super User 2025 Season 1 on at
    RE: Auto-remove OData entity if error encountered

    Hi tl2022,

    Can you elaborate on the exact error(s) and what records are then in the application for this entity?

  • huijij Profile Picture
    huijij 19,811 on at
    RE: Auto-remove OData entity if error encountered

    Hi sir,

    Are you trying to delete the wrong OData record? You can use the data entity to delete the record.  OData enabled data entities can be used to delete records as well. What is your real bussiness requirement?

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,074 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,900 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans