Wednesday 3 December 2014

Table inheritance in Ax 2012


Step-1 Create a table called 'BaseTable'
Step-2 Set table property 'supportInheritance' to 'Yes'
Step-3 Create a filed name called 'InstanceRelationType' extends 'RelationType'
Step-4 Set table property 'InstanceRelationType' to 'InstanceRelationType'
Step-5 Create two filed called Id and Name as shown below screen
Step-6 Create another table called 'ChildTable'
Step-7 Set table property 'supportInheritance' to 'Yes'
Step-8 Set table property 'Extends' to 'BaseTable'
Step-9 Write a job to access the base table fields given below

static void dataInsert_BaseTable(Args _args)
{
BaseTable bt;
ChildTable ct;

ct.Id = '1000';
ct.Name = 'Test';
ct.insert();
}

Tuesday 2 December 2014

Collection Classes in Ax 2012

Array 
     Array's can hold values of any single data type and allows duplicate values and insertion of data is based on the location Specific. 


Static void Array_example(Args _args)

{
Int I;
Array arr=new Array(Types::String);
arr.value(1,”ABC”);
arr.value(2,”ABCD”);
arr.value(3,”ABCDE”);
for(i=1;i<=arr.lastindex();i++)
{
Info(strfmt(“Value is: %1”,arr.value(i)));
}
}



List   
 List Contains elements that are accessed sequentially. Unlike the Array class, the List class provides an addStart() method. As with the Set class, the List class provides methods getEnumerator() and getIterator(). You can use an iterator to insert and delete items from a List object. It allows duplicate values.


Static void List_example(Args _args)
{
List l=new List (Types::Integer);
ListEnumerator lenum;
l.addEnd (20);
l.addEnd (24);
l.addStart (30);
l.addStart (25);
lenum= l.getEnumerator();
lenum.reset();
  While (lenum.movenext())
    {
             Info (strfmt(“Value is: %1”,lenum.current()));
     }


Map

 Map Associates a key value with another value. It doesn't allow duplicate Key values in Maps.

Static void Map_example(Args _args)
{
Map m=new Map (Types::String,Types::Integer);
MapEnumerator menum;
m.insert(“Vlaue1”, 20);
m.insert(“Vlaue2”, 30);
m.insert(“Vlaue3”, 60);
menum= m.getEnumerator();
While (menum.movenext())
{
Info (strfmt(“Value is: %1 || Key is: %2 ”,menum.currentValue(),menum.currentKey()));
}
}

Set
Holds values of any single type. Values are not stored in the sequence they are added. Instead, the Set object stores them in a manner that optimizes performance for the in() method. When you add a value to a Set object which is already storing that same value, the add attempt is ignored by the Set object.Unlike the Array class, the Set class provides the methods in() and remove().
Static void Set_example(Args _args)
{
Set s=new Map (Types::Integer);
SetEnumerator senum;
s.add( 20);
s.add( 25);
s.add( 60);
senum= s.getEnumerator();
While (senum.movenext())
  {
     Info (strfmt(“Value is: %1 “,senum.current()));
  }
}

Struct
Can contain values of more than one type. Used to group information about a specific entity.

Static void Struct_example(Args _args)
{
Int i;
Struct s=new Struct ();
s.add(“Name”,”ABC”);
s.add( “Age”, 34);
s.add( “Salary”,23000.00);
for(i=1;i<=s.fields();i++)
  {
    Info (strfmt(“Field Type: %1 || Field Name: %2 || Value      is:%3“,s.fieldType(i),s.fieldName(i),s.value(s.fieldName(i))));
  }
}

Friday 28 November 2014

Args Class in Microsoft Dynamics Ax

                                        Args class

The Args system class is one of the most widely used classes in Axapta. Args is an abbreviation for arguments and an Args object is used to pass information from one object (caller) to another newly created object.


Using Args for object creation

//This Example explain about opening a Form through Args.

 Args    args = new Args("CustTable");
 FormRun formRun = ClassFactory.formRunClass(args);
 ; 
 formRun.init();
 formRun.run();
 formRun.wait();    or  formRun.detach();

Caller:

public Object caller( [Object _value] )

this method gets or sets the calling object. When creating an args object directly through code, the caller will not be automatically set, so you should set it yourself.

Record:

public Common record( [Common _value] )

this method gets or sets a table buffer (record) attached to the Args. A buffer of any table can be attached to an Args object using this method. Be aware when retrieving the buffer that there will be no compile-time check of table id. You should use the dataset method below to check the contents of the buffer.

If the caller and callee are on different tiers, then the applications will automatically copy the buffer to the target tier.

Dataset:

public tableId dataset()

this method gets the table Id of a table buffer (record) attached to the Args.
To safely retrieve an attached record from an Args object, use code similar to that shown below. This checks to ensure that there is an attached record, and that it is in fact a SalesTable record, before trying to assign it to the salesTable variable.

if (args.record() && args.dataset() == tableNum(SalesTable))
  salesTable = args.record();

parm:

public str parm( [str _value] )
parm is used to pass a string variable to the called object

parmEnum:

public anytype parmEnum( [int _value] )

parmEnumType:

public int parmEnumType( [int _value] )

parmEnum and parmEnumType are used together to pass a Base Enum value through to the called object. An example is shown below.

args.parmEnumType(EnumNum(AddressType));
args.parmEnum(AddressType::Delivery);

parmObject:

public Object parmObject( [Object _value] )
parmObject is used to pass a reference to any object to the called object. Be aware of client-server issues if the caller and callee are on different tiers.

menuItemName:

public final str menuItemName( [str _value] )

menuItemType:

public final MenuItemType menuItemType( [MenuItemType _value] )

A short tutorial on how to open a form in Dynamics Ax (Axapta) by code.

Just take a line of code:

new MenuFunction(MenuItemDisplayStr(CustTable),MenuItemType::Display).run();
The above code will open the CustTable form. That's all it takes.

Now if you want to supply some arguments to the opening form, this is also possible with the optional args parameter.

static void FormOpen()
{
Args args = new Args();
;
args.record(CustTable::find('1002'));
new MenuFunction(MenuItemDisplayStr(CustTable),MenuItemType::Display).run(Args);
}

This code will open the CustTable form and filter out the customer with accountnumber 1002.


Thursday 20 November 2014

Link Type and Join Types in ax 2012

Link Type and Join Types in ax 2012


Link Type:-

1.      Active: - Parent and child- data source is updated immediately when a new record in the parent data source is selected. Continuous updates consume lots of resources consuming.

2. Delayed: - Parent and child - A pause is inserted before linked child data sources are updated. This     enables faster navigation in the parent data source because the records from child data sources are not updated immediately. For example, you can scroll a list of orders where you do not want to review the lines associated with the order until you stop scrolling.

3. Passive: - Parent and child - Linked child data sources are not updated automatically. Updates of the child data source must be programmed on the active method of the master data source.

Join Types:-

1. InnerJoin: - Combined data source – select the record from the main table that matches records in the joined table and vice versa.
There is one record for each match. Records without related records in the other data source are eliminated from the result.

2. Outer Join: - Combined data source – select the records from the main table. The records are retrieved whether they have matching records in the joined table

3. Exist Join: - Combined data source -The data source retrieves a record from the main table for each matching record in the joined table.
The differences between InnerJoin and ExistJoin are as follows:
·         When the join type is ExistJoin, the search ends after the first match has been found.
·         When the join type is InnerJoin, all matching records are searched for.

4. NotExistJoin: - Combined data source -Select records from the main table that do not have a match in the joined table.

Tuesday 18 November 2014

PurchaseOrder Creation Process in Microsoft Dynamics Ax 2012

PurchaseOrder Creation Process:

They are 4 Major Process Steps involved in the Creation Of Purchase Order:
1. Confirmation/PurchOrder.
2. Receipt List
3. Packing Slip/Product Receipt
4. Invoice.

1. Confirmation Class's , Tables and Reports That are related to Confirmation process are following:
               Tables  : VendPurchOrderJour , VendPurchOrderTrans.
               Class's : PurchFormLetter_PurchOrder.

2. ReceiptList  Class's , Tables and Reports That are related to ReceiptList process are following:
            Tables  : VendReceiptListJour , VendReceiptListTrans.
            Class's : PurchFormLetter_ReceiptList.

3. PackingSlip/Product Receipt Class's , Tables and Reports That are related to PackingSlip process are following:
            Tables  : VendPackingSlipJour , VendPackingSlipTrans.
            Class's : PurchFormLetter_PackingSlip.

4. Invoive Class's , Tables and Reports That are related to Invoice process are following:
     Tables  : VendInvoiceJour , VendInvoiceTrans.
     Class's : PurchFormLetter_Invoice.


FORMS : PurchTable,PurchEditLines

Saturday 15 November 2014

SlaesOrder Creation Process:

SlaesOrder Creation Process:

They are 4 Major Process Steps involved in the Creation Of Sales Order:
      1. Confirmation.
      2. Picking List
      3. Packing Slip
      4. Invoice.


1. Confirmation Class's ,Tables and Reports  That are related to Confirmation process are following:
                Tables  : CustConfirmJour , CustConfirmTrans.
                Class's : SalesFormLetter_Confirm.
                Report : SalesConfirm.

2. PickingList Class's ,Tables and Reports That are related to PickingList process are following:
                Tables  : WMSPickingRout , WMSOrderTrans.
                Class's : SalesFormLetter_PickingList.
                Report : SalesPickingList.

3. PackingSlip Class's ,Tables and Reports That are related to PackingSlip process are following:
                 Tables  : CustPackingSlipJour , CustPackingSlipTrans.
                 Class's : SalesFormLetter_PackingSlip.
                 Report : SalesPackingSlip.

4. Invoice Class's, Tables and Reports That are related to Invoice process are following:
                  Tables  : CustInvoiceJour , CustInvoiceTrans.
                  Class's : SalesFormLetter_Invoice.
                  Report : SalesInvoice.

Saturday 8 November 2014

What Is The Difference Between OCC and PCC ?

Optimistic Concurrency Control (vs) Pessimistic Concurrency Control


Pessimistic Concurrency Control :
                                                    On updating the data, the record gets locked and no one else can access that record for updating. It becomes a read-only record till the lock is released. Once the lock gets released, the record can be locked again and get updated for a different user.

Optimistic Concurrency Control :
                                                    This allows multiple user to open up the same record for updation . Record gets locked only while updating the record. This is the most preferred way of locking for the web application.


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.

Tuesday 30 September 2014

Sequence of methods in the FORM level in AX




Sequence of methods in the FORM level in AX




This gives the information of method calls in the form level while

       1. Opening the Form.
       2. Creating/Updating/Deleting the record in the Form.
       3. Closing the Form.

Sequence of Methods calls while opening the Form

          Form --- init ()
          Form --- Datasource --- init ()
          Form --- run ()
          Form --- Datasource --- execute Query ()
          Form --- Datasource --- active ()

Sequence of Methods calls while closing the Form

         Form --- canClose ()
         Form --- close ()

Sequence of Methods calls while creating the record in the Form

        Form --- Datasource --- create ()
        Form --- Datasource --- initValue ()
        Table --- initValue ()
        Form --- Datasource --- active ()

Sequence of Method calls while saving the record in the Form

           Form --- Datasource --- ValidateWrite ()
          Table --- ValidateWrite ()
          Form --- Datasource --- write ()
          Table --- insert ()

Sequence of Method calls while deleting the record in the Form

            Form --- Datasource --- validatedelete ()
            Table --- validatedelete ()
            Table --- delete ()
            Form --- Datasource --- active ()

Sequence of Methods calls while modifying the fields in the Form

          Table --- validateField ()
          Table --- modifiedField ()

Friday 19 September 2014

What is a Dialog in Ax 2012?




                                                                 Dialogs

  • Dialogs should allow users to enter some simple values. 

Dialog Classes :

  • Dialog is the main class used to construct dialogs.
  • DialogRunBase is an extension of the Dialog class that is used by the RunBase framework.
  • The DialogControl class defines a single control in the dialog. 

Main Classes used in Dialog Box are 
  •   Dialog
  •   DialogField
  •   DialogGroup
  •   DialogTabPage
  •   DialogText

Dialog Method :

  •   addField( )
  •   addFieldValue( )
  •   addGroup( )
  •   value( )
  •   run( )

   

>>>  The following simple Example explain about the Dialog   


static void theAxapta_DialogBox(Args _args)
{
Dialog              dialog;
DialogGroup    dialogGroup;
DialogField      dialogField;
;
dialog              = new Dialog("Simple Dialog");
dialogGroup    = dialog.addGroup("Customer");
dialogField      = dialog.addField(extendedTypeStr(custAccount));
if (dialog.run())
{
info(strFmt("%1",dialogField.value()));
}
}







    1.   The dialog.run() method returns true if OK is clicked, and false if Cancel is  clicked.
    2.   Dialog Group is used to group dialog fields which are logically same.

>>>  The below example is showing about the .addFieldValue( )  . If we use this method we can directly pass the value to Dialog.






>>> The below Example shows using the Tabpages.








Thanks And Regards

Ranjith Reddy