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 :
Finance | Project Operations, Human Resources, ...
Unanswered

How to cancel super call of a button click event through extension?

(0) ShareShare
ReportReport
Posted on by 75

I want to add a check to the click event of a button, when check failed, I want to cancel the super call, how to do it?

I have tried to use FormControlCancelableSuperEventArgs and FormControlCancelEventArgs in event handler of clicking event, but both of them return null.

Below is my test code.

[FormControlEventHandler(formControlStr(LedgerJournalTable, Approve), FormControlEventType::Clicking)]
public static void Approve_OnClicking(FormControl sender, FormControlEventArgs e)
{
    FormControlCancelEventArgs	ce = e as FormControlCancelEventArgs;  // ce returns null
    FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;  // ce returns null too
}

I know I can complete it by throw exception, but I think it is not a official way.

So how can I cancel the super call by a official way?

I have the same question (0)
  • WillWU Profile Picture
    22,363 on at

    Hi bjdchw,

    FormControlCancelableSuperEventArgs would be applicable to certain form control events, one of them is the onLookup event. It does not support the onclick event of formcontrol.

    You could try to use a if-else block to skip super() call. It will be much better than throwing an exception.

  • bjdchw Profile Picture
    75 on at

    Hi Will Wu,

    Thank you for you reply.

    Call to 'next' should be done only once and unconditionally.

    So we can't use a if-else block to skip super() call.

  • Martin Dráb Profile Picture
    238,858 Most Valuable Professional on at

    As mentioned, your design can't be implemented. Throwing an exception is a feasible workaround, but not the only one. For example, maybe you could check the condition in active() and disable the button if it's not met. Or maybe you could put the validation to the object called by the button.

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 527 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 473

#3
Adis Profile Picture

Adis 284 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans