Get All Button in D365 FO/ AX 2012
class SCA_GetControlInForm
{
///
/// Runs the class with the specified arguments.
///
/// The specified arguments.
public static void main(Args _args)
{
Form myForm;
FormBuildDesign design;
FormBuildControl control;
int cnt = 0;
Set buttonsSet = new Set(Types::Class);
Args args;
void findButtons(FormBuildControl _buildControl)
{
FormBuildControl buildControl;
int i;
;
if (_buildControl.controlCount() > 0)
{
for (i = 1; i <= _buildControl.controlCount(); i++)
{
buildControl = _buildControl.controlNum(i);
findButtons(buildControl);
}
}
else
{
if (classidget(_buildControl) == classnum(FormBuildButtonControl) ||
classidget(_buildControl) == classnum(FormBuildCommandButtonControl) ||
classidget(_buildControl) == classnum(FormBuildDropDialogButtonControl) ||
classidget(_buildControl) == classnum(FormBuildMenuButtonControl) ||
classidget(_buildControl) == classnum(FormBuildFunctionButtonControl))
{
buttonsSet.add(_buildControl);
}
}
}
;
myForm = new Form("CustTable");
design = myForm.design();
for (cnt = 1; cnt <= design.controlCount(); cnt++)
{
control = design.controlNum(cnt);
findButtons(control);
}
}
}