Announcements
Hello Guys,
I want to disable a menu item button under conditions, I did my work on the eventHandler "OnClicked" but the order is coming after we click and finish the process. I want to prevent the user from continuing the confirm button process several condition, so I moved my code to the Activated Event Handler on the form
but no class is working for the button neither the FormControl , FormButtonControl or the FormMenuButtonControl and FormFunctionButtonControl
the function I'm using is sender.FormRun().design(0).ControlName("MENUITEMNAME").enabled(false);
even i tried to remove the (0) from the design but all is the same, nothing is working,
the error i'm receiving in the system is"Unable to cast object from type 'FormControl.buttonConfirm' to type 'Dynamics.AX.Application.FormButtonControl' or any type i chose other than FormControl
and on the FormControl class also don't work.
Ah ha,
Then I think got the issue.
You can see on PurchTable we have method: enableJournalButtons() to enable or disable the confirm button.
As buttonConfirm is auto declared so you can just extend enableJournalButtons, add your logic after the next call and call buttonConfirm.enabled(false);
The above issue is because you call on activated but later enableJournalButtons() is standardly called and enable the button again.
ah okay, i tried this before and also don't get any result.
i will try to apply my code on the UpdateDesign method on the level of the form
Hi,
You can remove your FC variable and every place instead of calling FC.Enabled(false); you can use:
sender.FormRun().design(0).ControlName("MENUITEMNAME").enabled(false);
Hi Komi Siabi
it did not worked, after doing this still the confirm button opened , i tried to test it and put the FC .enabled(false); in the event handler without conditions but still opened
Hi,
In this case, can you try to call the same code twice for sender.formRun().design()? This mean you will not use the FC variable to get the button.
Please check and let us know the result to validate further.
Hi AklG,
So you want to control the Confirm button based on some conditions. Writing on the Activated Event Handler on the form is fine. But do not forget that, the Confirm button is already controlled by the PurchStatus and DocumentState field.
///
André Arnaud de Cal...
294,217
Super User 2025 Season 1
Martin Dráb
232,978
Most Valuable Professional
nmaenpaa
101,158
Moderator