Friday 17 October 2014

CrossCompany and ChangeCompany in Microsoft Dynamics AX


How to retrieve data from multiple companies or all companies by using CrossCompany and ChangeCompany in AX.

CrossCompany:- By using this keyword we can retrieve data from multiple companies or from all companies.
          
                 Example:-
                    CustTable cust;
                    Container con;
                    con=["ceu","Dat","cee"];
                    Select crosscompany:con cust;
                    print cust.accountnum;
                    pause;


                 Example:-
                    CustTable cust;
                    Select crosscompany cust;
                    print cust.accountnum;
                    pause;


ChangeCompany:- By using this keyword we can change company any time and retrieve data from specific companies.

                Example:-
                    CustTable cust;
                    Select *from cust;
                    print cust.accountnum;
                    changecompany("Cee")
                    {
                     cust=null
                    Select *from cust;
                    print cust.accountnum;
                     }
                    changecompany("Ceeu")
                    {
                     cust=null
                    Select *from cust;
                    print cust.accountnum;
                     }
                    pause;

Saturday 4 October 2014

What is a Box in ax 2012?




                                          BOX CLASS


Boxes display brief messages to application users. There are many box types and each has their own box method.

Methods in the box class take the following parameters:
      • The main text
      • The title bar text
      • Help text

The following is an example of an information box and how the parameters are used:
      
          Box::info("Main Text", "Title", "This is the help text");

The following figure shows the resulting window.


                                                          

The string "This is the help text" appears in the status bar at the bottom of the screen.

The box class contains many methods that create different types of boxes. These methods can be viewed in the AOT under Classes > Box. Many boxes only provide output to the user, where as other boxes accept input from the user, depending on which button the user clicks.

Some of the more commonly used boxes are discussed in this lesson. The warning box is used to display warning messages.

The following example shows how the warning message is used:


Box::warning ("This is a warning message.", "Title text", "Help text");

The resulting box is shown on the display.

                         

The following example shows a YesNo box:

         Box::yesNo("Choose Yes or No", DialogButton::Yes, "Yes No Box Example", "Answer Yes or No");


The resulting box is shown on the display.

                                          

Notice the additional required parameter DialogButton::Yes. This parameter specifies a default button. Notice on the YesNo box that the Yes button is selected as the default.

The following is an example of how X++ accepts user input and executes statements based on this input:


    DialogButton dialogButton;
    dialogButton= Box::yesNo("Choose Yes or No",
    DialogButton::Yes, "Yes No Box Example");

    if (dialogButton == DialogButton::Yes)
           {
              print "You chose Yes";
              pause;
            }
  else if (dialogButton == DialogButton::No)
           {
              print "You chose No";
              pause;
            }



The box function returns a value of the enum DialogButton that can be used to determine which option the user chooses.