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 :
Small and medium business | Business Central, N...
Answered

Prevent deletion of item from D365 BC and insert failed response into Integration Logs table

(0) ShareShare
ReportReport
Posted on by 241
When an item is deleted in Business Central, I trigger a call to a third-party API to delete the corresponding item in the third-party application. Additionally, I maintain integration logs to record whether the API call was successful, resulted in an error, or generated a warning.

trigger OnAfterDelete()
    var
        ABC: Codeunit ABC;
    begin
        ABC.DeleteItemFrom3rdPatyApp(Rec./No./);
    end;

I make this API call within the OnAfterDelete trigger in the Item table extension. However, if an error occurs from the third-party application, I need to insert the error response into the Integration Logs table and also need to show that error to the user in the web client. The challenge here is that when an error occurs, Business Central automatically rolls back all transactions, including the insertion of the error response into the Integration Logs table. 

When I use the Commit() function, it also deletes the corresponding item from BC.

My goal is to prevent the deletion of the item from Business Central in the OnAfterDelete() trigger while still being able to insert the failed response into the Integration Logs table. If anyone could provide guidance on how to achieve this functionality, I would greatly appreciate it. Thank you for taking the time to read this.
I have the same question (0)
  • Verified answer
    YUN ZHU Profile Picture
    95,329 Super User 2025 Season 2 on at
    Hi, I don't know exactly what is implemented in the 3rd party app, but is it possible without throwing an error in BC, like using Try methods/functions.
     
    Hope this gives you some tips.
     
    Thanks
    ZHU

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,226

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,047 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,257 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans