Hello, I have added a menu item button to a form extension. If the user clicks on it I need to check a condition and if it is not true then I want to display a message and prevent the display menu item form that the button references from opening. In my event handler class I have the onclicked event handler of the button and the following code.
if (svcCallTable.CustAccount == '') {
throw error('You must select a customer account before adding new contacts!');
FormControlCancelableSuperEventArgs ce = e as FormControlCancelableSuperEventArgs;
ce.CancelSuperCall();
}
The problem is that the called form still opens and the message displays on that form. I need to prevent the called form from opening and display the message on the caller form. How can I do that?
Hello Kurt Warner,
Do you still have any issue on this thread? Would you please mark it as verified if it helps.
Hello Kurt Warner,
This is because the code after "throw error" statement will not be executed.
The throw statement should be used only if a piece of code cannot do what it is expected to do. The throw statement should not be used for more ordinary program flow control.
So you can put the line of throw error('You must select a customer account before adding new contacts!') after CancelSuperCall( ), Or you can consider using the warning or info instead.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156