Saturday, November 24, 2012

Duplicate AX 2012 SSRS Reports through wizard


Its duplicate DP class, Contract class and UIBuilder classes. 

This wizard will take 5-20 minutes to duplicate all the artifacts .
image

image
image
image
image
Below is the private project which the wizard creates for you with the required classes , report and CSharp business logic project.
image

Wednesday, November 14, 2012

Select multiple records from lookups in Dynamics AX 2012

Select multiple rows from lookups by using a  SysLookMultiSelectCtrl class.
Create a Query named StudentCourse that will contains 2 datasources i.e Student & Course as shown in the below figure.


Now create a new form named MultiSelectLookupCtrl and add a StringEdit control named as TestCtrl in the design node.Set its AutoDeclaration property to "Yes"
Now override the following methods and write the following code.

In the ClassDeclaration of the form write the below code.

public class FormRun extends ObjectRun
{
    SysLookupMultiSelectCtrl msCtrl;
}

Override the init method of the form and place the below code


public void init()

{
    super();
    // TestCtrl - Name of control on which you want a lookup.
   // StudentCourse - Query to get the lookup data
    msCtrl = SysLookupMultiSelectCtrl::construct(element, TestCtrl, querystr(StudentCourse));
}


Select multiple records from the lookup.






To get the values and RecId of the selected rows records, override the modified method of the TestCtrl control and add the below code.

public boolean modified()
{
    boolean ret;
    container c,v;
    int i;
    ret = super(); 
    if (ret)
    {
        c = msCtrl.get();  // get RecIds of the selected rows
        v = msCtrl.getSelectedFieldValues(); // get actual value of the selected rows
        for (i = 1; i <= conLen(c);i++)
        {
            info(conPeek(c,i));
            info(conPeek(v,i));
        }
    }
    return ret;
}

Retrieve multiple selected records from Grid using X++. in AX dynamics 2012


Retrieve all selected records of a datasource in a Grid

    int             recordsCount;
    Student     studentLocal;
    super();
    
    recordsCount = student_ds.recordsMarked().lastIndex();  // Total no of marked records.
    studentLocal = student_ds.getFirst(1);
    
    while (studentLocal)
    {
        info(studentLocal.Name +" " +studentLocal.ID);
        studentLocal = student_ds.getNext();
    }