Search This Blog

Wednesday, November 20, 2013

How to add Filter functionality to Display method in dynamics AXAPTA

Hi Friends,


Normally filters will work only in table fields but we can't do filters to display method.

This below code will work for filters to display method also.

Step 1:
Go to the form design right click on particular control properties Auto Declaration No to Yes.



Step 2:
Override the context() method on the display method .

public void context()
{
    int             selectedMenu;
    formrun         fr;
    Args            ag;
    Name            strtext;
    querybuilddataSource qb1;
    queryrun    qr;
    query       q;
    PopupMenu menu = new PopupMenu(element.hWnd());
    int a = menu.insertItem('Filter By Field');
    int b = menu.insertItem('Filter By Selection');
    int c = menu.insertItem('Remove Filter');
    ;
q   = ItemControl_ds.query();
qb1 = q.dataSourceTable(tablenum(ItemControl));
qb1 = qb1.addDataSource(TableNum(SalesTable));
qb1.addLink(FieldNum(ItemControl,PO),FieldNum(SalesTable,PurchOrderFormNum));  

selectedMenu = menu.draw();
    switch (selectedMenu)
    {
    case -1: //Filter by field
            break;
    case a:
            ag = new args('SysformSearch');
            fr = new formrun(ag);
            fr.run();
            fr.wait();
//Reading User entered value for filter process
            strtext = fr.design().controlName('FindEdit').valueStr();
            if(strtext)
            {
//Creating a query for filter
                
                qb1.addRange(FieldNum(SalesTable,SearchName)).value(strtext);
                ItemControl_ds.query(Q);
                ItemControl_ds.executeQuery();
            }
            break;

    case b:                                      // Filter By Selection
           
            qb1.addRange(FieldNum(SalesTable,SearchName)).value(ProjName.valueStr());
            ItemControl_ds.query(Q);
            ItemControl_ds.executeQuery();
            break;

    case c :                                      // Remove Filter
            q   = new Query();
            qb1 = q.addDataSource(tablenum(ItemControl));
            qb1.clearLinks();
            qb1.clearRanges();
            ItemControl_ds.query(Q);
            ItemControl_ds.removeFilter();
            break;

    Default:
            break;
    }

}
After adding the above code we are getting menus like 


Happy Daxing..



Thursday, November 14, 2013

How to pass control value in form to class in AXAPTA

How to pass control value from from to class in AX2009

Step :1

Write the method in Form level like :

public str method1()

{

         return control.Text();

}
Step 2:

Write this code in class level where we need to use the value

 if(formHasMethod(args.caller(), identifierStr(MethodName)))
    {
       strcustname =  args.caller().MethodName();
   

   }


Happy Daxing...!

Tuesday, November 12, 2013

Avoid warning message for "Empty compound statement" in AXAPTA

How to  avoid warning message like "Empty compound statement" in AXAPTA

As:
Simply call the below method inside your while loop or catch block to avoid best practice error

Call exceptionTextFallThrough(); in the block. It does nothing, it's there just to say that you're intentionally not doing anything there (and to satisfy compiler).


Happy
Daxing.....