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 :
Microsoft Dynamics AX (Archived)

Is it possible to cancel the call to super() in a class method using Pre/Post Event Handlers in class extension?

(0) ShareShare
ReportReport
Posted on by 3,208 Moderator

I was wondering if there was a way to cancel the call to super like we can do in Form extensions in Form control event handlers. For instance: 

public void method(Object _obj)
{

super(_obj);
// some logic }

It seems like wishful thinking but, I need to call super only after that logic is executed.

So I was wondering if there was a way to cancel the call to super in the PreHandler of this method and then call it again in the PostHandler?

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    No, you can't somehow skip a piece of code inside a method. The only thing you can do is interrupting the whole execution by throwing an exception.

    If you want to run something before the rest of the method, use a pre-method event. If you need to change code inside a method, you need overlayering or asking the author (most likely Microsoft) to make the logic extensible.

  • Zain Bokhari Profile Picture
    3,208 Moderator on at

    Thanks Martin.

  • badduke Profile Picture
    259 on at

    Hi Zain,

    Did you tried the below approach.

        FormControlCancelableSuperEventArgs     eventArg = e as FormControlCancelableSuperEventArgs;

        eventArg.CancelSuperCall();

  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    That would be applicable to certain form control events, but not to pre-/post-event handlers as required by Zain.

    He's clearly aware of this option, because he mentioned he wanted something "like we can do in Form extensions in Form control event handlers".

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 > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans