Wednesday, September 5, 2012

Add Search/ Find /Filter functionality to Display method in dynamics AX

Dynamics AX, can retrieve output values by using table field and display method. As we know, usually standard dynamics AX filter functionality is working only for table field. But sometimes we have to do filter functionality for display method too. Below I’m going to explain how to add a filter functionality for Display method.

1.      Here I have added display method (disCustName) to display customer name on the “IND_BusRelation” form. In this form main data source is “smmBusRelTable”.

2.      Change “AutoDeclaration” property from No to Yes of the “disCustName” data field.
3.      Override “context()” method of the “disCustName” data field and add following code.
  
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');
    ;

    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
                q   = smmBusRelTable_ds.query();
                qb1 = q.dataSourceTable(tablenum(smmBusRelTable));
                qb1 = qb1.addDataSource(TableNum(CustTable));
                qb1.addLink(FieldNum(smmBusRelTable,CustAccount),FieldNum(CustTable,AccountNum));
                qb1.addRange(FieldNum(CustTable,Name)).value(strtext);
                smmBusRelTable_ds.query(Q);
                smmBusRelTable_ds.executeQuery();
            }
            break;

    case b:   // Filter By Selection
            q   = smmBusRelTable_ds.query();
            qb1 = q.dataSourceTable(tablenum(smmBusRelTable));
            qb1 = qb1.addDataSource(TableNum(CustTable));
            qb1.addLink(FieldNum(smmBusRelTable,CustAccount),FieldNum(CustTable,AccountNum));
            qb1.addRange(FieldNum(CustTable,Name)).value(disCustName.valueStr());
            smmBusRelTable_ds.query(Q);
            smmBusRelTable_ds.executeQuery();
            break;
    case c :   // Remove Filter
            q   = new Query();
            qb1 = q.addDataSource(tablenum(smmBusRelTable));
            qb1.clearLinks();
            qb1.clearRanges();
            smmBusRelTable_ds.query(Q);
            smmBusRelTable_ds.removeFilter();
            break;

    Default:
            break;
    }

}

4.       Run the form and do right Click on Customer Name field.


 
Source:http://dynamicsaxsolutionsworld.blogspot.in/2011/09/how-to-add-search-find-filter.html

Tuesday, June 21, 2011

Build list of Printers

The following example shows how to use SysPrintOptions to display a list of all
available printers.
static void ShowListOfPrinters(Args _args)
{
    printJobSettings printJobSettings;
    sysPrintOptions sysPrintOptions;
    map printerMap;
    mapIterator mapIterator;
    ;
    printJobSettings = SysPrintOptions::newPrintJobSettingsOnServer();
    sysPrintOptions = new sysPrintOptions();
    sysPrintOptions.setPrintJobSettings(printJobSettings);
    sysPrintOptions.buildPrinterMap();
    printerMap = sysPrintOptions.getPrinterMap();
    mapIterator = new mapIterator(printerMap);
    mapIterator.begin();
    while (mapIterator.more())
    {
        info(mapIterator.value());
        mapIterator.next();
    }
}

Thursday, May 5, 2011

How to Shut Down the Axapta through X++

Hi,
Here is the code for Shut Down Axapta.

public static void ShutDownAxapta()
{
    info info;
    ;
     info=new info();
     info.shutDown(true);
}

Wednesday, May 4, 2011

Microsoft Dynamics AX 2012 Resource



Hi Friends,
Here is the Microsoft Dynamics AX 2012 Stuff

Functional Demos