1

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  ce1 = e as FormControlCancelEventArgs;  // ce1 returns null
    FormControlCancelableSuperEventArgs ce2 = e as FormControlCancelableSuperEventArgs;  // ce2 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?

bjdc
  • 11
  • 1
  • 2
  • I believe that the FormControlCancelableSuperEventArgs class is only available for JumpRef and OnLookup events. – rjv Mar 01 '21 at 14:04

1 Answers1

0

I don't think it's possible to achieve what you want to. The super() call in the Approve button on the LedgerJournalTable form is doing nothing outside of the frameworks form management such as screen refresh and other tasks that won't affect the logic (because it is a regular button and NOT a menu item button). The button is creating a new menu function in code and calling it explicitly, but is not actually calling the menu item in the super() call.

I would create another approve button in an extension, hide the out-of-the-box button, and in your extension button's OnClicked event copy the logic from the original button, and then modify it in any way that you need, such as skipping the menu function call based on certain logic/conditions that your requirements dictate.

rjv
  • 1,058
  • 11
  • 29