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

OnDelete trigger should only executed when a certain condition is true

(0) ShareShare
ReportReport
Posted on by

Hey guys,

I have the following situation:

I have created a posting function. When I execute that function via my action on the page, the header and all lines are written to a posted header and to posted lines. Therefore I have created some objects. After writing the header and the lines to that other objetcs, the lines are deleted in the unposted objects.

The other thing is, the user can create via an anction out of one header and the associated lines a protocol. If he or she has forgotten a special line, he or she can add them and they are also added to the protocol. And if he or she deletes a line, they are also deleted in the the protocol. For the deletion the Ondelete trigger is exectued.

So now when I post, the program asks me to delete the associated line from the protocols...because the Ondelete trigger is exectued. But this is not I want to do...

So I need a condition, which is true or false, so separate the two function.

I did created the following code:

7571.Error.PNG

I hope it is possoble to understand my issue...

Thank you ;)

I have the same question (0)
  • Verified answer
    Avinash B Profile Picture
    1,455 on at

    Hi

    You can use Delete(true) if you want to run code on the OnDelete trigger. Use only Delete() if you don't want to code to execute.

    I hope this would solve your issue.

    Regards

    Avinash B

  • Community Member Profile Picture
    on at

    That was the idea to solve my issue ;)

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,028 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,121 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 669 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans