Get All Button in D365 FO/ AX 2012 - Microsoft Dynamics 365 Vietnam

Microsoft Dynamics 365 Vietnam

Song Nghia - Microsoft Dynamics 365 Vietnam

Breaking

Thursday, November 21, 2019

Get All Button in D365 FO/ AX 2012


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);
        }
    }
}