Thursday 26 May 2016

History of Microsoft Dynamics AX

                     Historically, Microsoft Dynamics AX encompasses more than 25 years of experience in business application innovation and developer productivity. Microsoft acquired the predecessor of Microsoft Dynamics AX, called Axapta, in 2002, with its purchase of the Danish company Navision A/S. The success of the product has spurred an increasing commitment of research and development resources, which allows Microsoft Dynamics AX to grow and strengthen its offering continuously.

                    The development team that created AX 2012 consists of three large teams, two that are based in the United States (Fargo, North Dakota, and Redmond, Washington) and one that is based in Denmark (Copenhagen). The Fargo team focuses on finance and human resources (HR), the Redmond team concentrates on project management and accounting and customer relationship management (CRM), and the Copenhagen team delivers supply chain management (SCM). In addition, a framework team develops infrastructure components, and a worldwide distributed team localizes the Microsoft Dynamics AX features to meet national regulations or local differences in business practices in numerous languages and markets around the world.
                 
                   To clarify a few aspects of the origins of Microsoft Dynamics AX, the authors contacted people who participated in the early stages of the Microsoft Dynamics AX development cycle. The first question we asked was, “ How was the idea of using X++ as the programming language for Microsoft Dynamics AX conceived ?”
                   We had been working with an upgraded version of XAL for a while called OO XAL back in 1996/1997. At some point in time, we stopped and reviewed our approach and looked at other new languages like Java. After working one long night, I decided that our approach had to change to align with the latest trends in programming languages, and we started with X++. --Erik Damgaard Cofounder of Damgaard 

              Data Of course, the developers had several perspectives on this breakthrough event. One morning when we came to work, nothing was working. Later in the morning, we realized that we had changed programming languages! But we did not have any tools, so for months we were programming in Notepad without compiler or editor support. --Anonymous developer
           
             Many hypotheses exist regarding the origin of the original product name, Axapta. Axapta was a constructed name, and the only requirement was that the letter X be included, to mark the association with its predecessor, XAL. The X association carries over in the name Microsoft Dynamics AX.

Wednesday 18 May 2016

Lookup in Ax 2012

Override Lookup() Method and Copy the below Code

public void lookup()
{
    Query query = new Query();
    QueryBuildDataSource         qbds;
    QueryBuildRange                 queryBuildRange;
    SysTableLookup                   sysTableLookup;
    super();

    sysTableLookup         =  sysTableLookup::newParameters(tableNum(Dipl_EmployeeMaster), this);
    sysTableLookup.addLookupfield(fieldnum(Dipl_EmployeeMaster, Name), true);
    qbds   = query.addDataSource(tablenum(Dipl_EmployeeMaster));
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();

}

Tuesday 17 May 2016

How to Get Tax value based on Tax Group using X++ Code


TaxGroupData                taxGroupData ;
PurchLine                       purchLine;

while select taxGroupData where
              taxGroupData.TaxGroup == purchLine.TaxGroup
   {
                if(taxGroupData.RecId)
                {
                    taxValue  +=  taxGroupData.showTaxValue(); // if there are Tax combinations
                }
    }

Thursday 12 May 2016

Type Conversions in Ax 2012

Enum2int() Method

static void Datatypes_enum2int(Args _args)
{
    SalesType salesType;
    salesType = SalesType::Sales;
    info(strfmt("The value of the current sales-type element is %1",enum2int(salesType)));
}

Enum2Str() Method

static void Datatypes_enum2str(Args _args)
{
    SalesType salesType;
    salesType = SalesType::Sales;
    info(strfmt("The name of the current sales-type is '%1'", enum2str(salesType)));
}

anytype
static void Raj_anytype(Args _args)
{
    anytype any;
    any = "ABC";
    print any;
    any = 55;
    print any;
    any = systemdateget();
    print any;
    pause;
}

Friday 6 May 2016

How to create Worker to Vendor using X++ Code in Ax 2012

static void Raj_WorkertoVendorCreate(Args _args)
{
    VendTable                           vendTable;
    HcmWorker                           hcmWorker;
    LogisticsLocation                   logisticsLocation;
    HcmEmployment                       hcmEmployment;
    ;

    try
    {
        while select hcmWorker
            join hcmEmployment
                where hcmEmployment.Worker == hcmWorker.RecId
                    && hcmEmployment.EmploymentType == HcmEmploymentType::Employee
        {
            ttsbegin;
            changeCompany(CompanyInfo::findRecId(hcmEmployment.LegalEntity).DataArea)
            {

                if(VendTable::find(hcmWorker.PersonnelNumber))
                {
                    //updates vendor(If we edit details i.e name)
                    vendTable = VendTable::find(hcmWorker.PersonnelNumber,true);
                    if(DirPartyTable::findRec(vendTable.Party).PrimaryAddressLocation)
                    {
                        logisticsLocation = LogisticsLocation::find(DirPartyTable::findRec(vendTable.Party).PrimaryAddressLocation);
                        if(logisticsLocation)
                        {
                            //Party location
                            DirParty::addLocation(vendTable.Party, logisticsLocation.RecId, true, true, false, [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Home).RecId]);
                        }
                    }
                    if(vendTable.DefaultDimension != hcmEmployment.DefaultDimension)
                        vendTable.DefaultDimension = hcmEmployment.DefaultDimension;

                    if(vendTable.validateWrite())
                    {
                        vendTable.update();
                       // info(strFmt("Vendor - %1 is Updated", vendTable.AccountNum));
                    }
                    else
                        throw error("Please enter valid details");
                }
                else
                {
                    //Location
                    if(DirPartyTable::findRec(hcmWorker.person).PrimaryAddressLocation)
                    {
                        logisticsLocation = LogisticsLocation::find(DirPartyTable::findRec(hcmWorker.person).PrimaryAddressLocation);
                        if(logisticsLocation)
                        {
                            //Party location
                            DirParty::addLocation(hcmWorker.person, logisticsLocation.RecId, true, true, false, [LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Home).RecId]);
                        }
                    }

                    //Party location
                    DirParty::addLocation(hcmWorker.person, logisticsLocation.RecId, false, true, false);

                    //creates Vendor
                    vendTable.clear();
                    vendTable.initValue();

                    vendTable.AccountNum = hcmWorker.personnelNumber;
                    vendTable.Party = hcmWorker.person;

                    vendTable.VendGroup = "EMP";
                    vendTable.initFromVendGroup(VendGroup::find("EMP"));

                    vendTable.Currency = CompanyInfo::standardCurrency();
                    vendTable.DefaultDimension =hcmEmployment.DefaultDimension;


                    if (vendTable.validateWrite())
                    {
                        vendTable.insert();
                        //info(strFmt("Vendor - %1 is created", vendTable.AccountNum));
                    }
                    else
                        throw error("Please enter valid details");
                }
            }
            ttscommit;
        }
    }
    catch
    {
        throw error("Error while creating/updating vendor.");
    }

}

Thursday 5 May 2016

To know that how many times that particular class extends using x++ code in Ax 2012

static void Raj_FindClass(Args _args)
{
    treeNode childNode;
    treenodeIterator it;
    str properties;
    str className;
    str extend;
    str searchType = "Salesformletter";  
    int x;
    treeNode t  = TreeNode::findNode('\\Classes');
    ;

    it = t.AOTiterator();
    childNode= it.next();
    while (childNode)
    {
        className = childNode.treeNodeName();
        properties = childNode.AOTgetProperties();
        extend = findProperty(properties, "Extends");

        if (extend == searchType)
        {
            info(strfmt("%1 – ExtendedDataType: %2", className,extend));
        }
     
        childNode= it.next();
    }
     

}