Hello All, Another task I have been given is to disable a certain command button in a form if the status of a field in the Sales Header is of a certain value. What procedure should I take to do this? Thanks
Hello, You can use ENABLED() function. For example, if BTNCommand1 is the name your button, you can use the folowing code : CurrForm.BTNCommand1.ENABLED(FALSE) // to disable the button CurrForm.BTNCommand1.ENABLED(TRUE) // to enable IF CurrForm.BTNCommand1.ENABLED THEN … // to test Maybe, you have to refresh the form with CurrForm.UPDATECONTROLS (depends on the trigger) I hope this help you Patrick
If this is to be decided when the form opens, use the OnOpenForm trigger. In OnInit, the form’s controls will not yet have been created. If you need to update the button’s status whenever the field changes, you can use one of the validation or modification triggers.
Hello Both, thanks for your help, I am making some good progress now. However, this only works for new controls I have created. i.e. The new controls I create go automatically to the Control part of the CurrForm section within c/al symbol menu. Control that already exist, for example “Make Order” which is Control68, are not available when you press F5 to access the controls. I get the message that I have to declare it as a variable?? Any ideas? Thanks again
I was about to post this last night but then I said Nahh… [:p] Remember that you have to name the Control before you start using it through code. Just set the Name property to something appropriate and it will show up in C/AL Symbol Menu (F5).
Thanks all…this is now working fine. I used the following as my main code: CurrForm."".ENABLED:=“Approval Status”=“Approval Status”::“Fully Commercially Approved”; I placed this within OnAfterGetRecord and OnValidate within the field. This allows me to ensure that the button has the correct status when scrolling through the records and also to ensure that the button has the correct status when the approval status is changed in the header table. Best Regards