Monday, 25 January 2016

Parallel compile through command prompt 

1. change the directory to the path where axbuild.exe file exits
Eg : cd E:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin
2. Run the following command
Eg: E:\Program Files\Microsoft Dynamics AX\60\Server\MicrosoftDynamicsAX\bin>axbuild.exe xppcompileall /aos=01 /altbin="E:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin" /workers=6


Wednesday, 9 December 2015

To Export a model using command prompt:

1. Open command prompt as run as administrator
2. change the directory to management utilities 
for ex: if the managementUtilities are present in E:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities
3. change directory to E drive using cd E:
4. once the directory is changed enter the command E:> E:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities
5. E:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities> axutil export /model:DES /file:BPCheck (where DES is the existing model and BPCheck is the filename we need to export) 
Finally the model will be exported to E:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities.

Friday, 4 December 2015

To Find the phone number of the customer:


    LogisticsElectronicAddress LogisticsElectronicAddress;
    DirPartyLocation DirPartyLocation;
    int contactPhoneCounter = 0;

    while select Locator from LogisticsElectronicAddress exists join DirPartyLocation
    where
    DirPartyLocation.Party == _custInvoiceJour.custTable_InvoiceAccount().Party
    &&
    DirPartyLocation.location == LogisticsElectronicAddress.location
    && LogisticsElectronicAddress.type == LogisticsElectronicAddressMethodType::Phone
    {
        contactPhoneCounter++;
        if (contactPhoneCounter==1)
        {
                cachedCompanyContactPhone1 = LogisticsElectronicAddress.Locator;
        }
        else if (contactPhoneCounter==2)
        {
            cachedCompanyContactPhone2 = LogisticsElectronicAddress.Locator;
        }
        else
        {
            break;
        }
    }

Thursday, 26 November 2015

Code to find Dimension Name:


public name hsGetDepartmentName(DimensionDefault  _dimensionDefault)
        {
             str                                 name;
              DimensionAttributeValueSetItem      valueSetItem; 
              DimensionAttribute                  dimAttribute; 
              DimensionAttributeValue             dimAttributeValue; 
            //Getting the Department name for the record.
              select DimensionAttributeValueSet from valueSetItem 
                    where valueSetItem.DimensionAttributeValueSet == _dimensionDefault 
                            join RecId from dimAttributeValue 
                                where valueSetItem.DimensionAttributeValue == dimAttributeValue.RecId 
                                    join RecId from dimAttribute 
                                        where dimAttributeValue.DimensionAttribute == dimAttribute.RecId 
                                              && dimAttribute.Name == enum2str(sysdimension::Department);
        
             name = DimensionAttributeValue::find(dimAttributeValue.RecId).getName();
        
            return name;
        }

To import demo data in AX 2012 R3:

1.       Install Test data transfer tool
2.       Open command prompt as administrator and then  cd\ C:\Program Files (x86)\Microsoft Dynamics AX 2012 Test Data Transfer Tool (Beta)
3.       Then type dp.exe import C:\Program Files (x86)\Microsoft Dynamics AX 2012 Test Data Transfer Tool (Beta) servername\axinstance name

Job for generating parm methods:


static void CreateAxBCParmMethod(Args _args)
{
    axGenerateAxBCClass axGenerateAxBCClass;

    axGenerateAxBCClass = AxGenerateAxBCClass::newTableId(tablenum(PurchReqLine));//tablenum can be the table                                                                                   //for which we want to generate                                                                                 //parm methods
    axGenerateAxBCClass.run();

}

Filter by field in ax 2012:

To have filter by filed option in ax 2012, we need to override context method at the control level in the design as shown below.

public void context()
{
    int             selectedMenu;
    formrun         fr;
    Args            ag;
    Name            strtext;
    querybuilddataSource qb1, qb2, qb3;
    classFactory    cf;
    query       q;
    #define.SysFormSearch('SysFormSearch')
    #define.FindEdit('FindEdit')
    PopupMenu menu = new PopupMenu(element.hWnd());
    int a = menu.insertItem("@DES212");
    int c = menu.insertItem("@DES213");
    ;

    selectedMenu = menu.draw();
    switch (selectedMenu)
    {
    case -1: //Filter by field
            break;
    case a:
            ag = new args(#SysFormSearch);
            cf = new classFactory();
            fr = cf.formRunClass(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   = custVendExternalItem_ds.query();
                qb1 = q.dataSourceTable(tablenum(custVendExternalItem));
                qb1 = qb1.addDataSource(TableNum(InventTable));
                qb1.addLink(FieldNum(custVendExternalItem,ItemId),FieldNum(InventTable,ItemId));
                qb2 = qb1.addDataSource(tableNum(EcoResProduct));
                qb2.relations(true);
                qb3 = qb2.addDataSource(tableNum(EcoResProductTranslation));
                qb3.relations(true);
                qb3.addRange(FieldNum(EcoResProductTranslation,Name)).value(strtext);
                custVendExternalItem_ds.query(Q);
                custVendExternalItem_ds.executeQuery();
            }
            break;

    case c :   // Remove Filter
            q = new Query();
            qb1 = q.addDataSource(tableNum(custVendExternalItem));
            qb1.addRange(fieldNum(custVendExternalItem, ModuleType)).value(strfmt("%1,%2",enum2str(ModuleInventPurchSalesVendCustGroup::Vend),
                enum2str(ModuleInventPurchSalesVendCustGroup::VendGroup)));
            custVendExternalItem_ds.query(Q);
            custVendExternalItem_ds.executeQuery();

            break;

    Default:
            break;
    }

}