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 :
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,361 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
    237,953 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

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans