To use number sequence based on the condition selected in Ax 2012

  After Creating The Number sequence we need to use based on the condition....like if u selected the year 2020 then number sequence start with the series 2020-###

    and if u select 2021 number sequence starts with series 2021-###.

For that we have to create two number sequences amd use them based on our condition like below code.

public void initValue()

{

    NumberSeq                numberSeq1,numberSeq2;

    DAXTestingMain                   dAXTestingLoc;

    super();

    dAXTestingLoc           = element.args().record();//using args to get the year from caller form


    if(dAXTestingLoc.DaxYear=='2021' && dAXTestingLoc.Action==NoYes::Yes)

    {


        numberSeq1 = NumberSeq::newGetNum(NumberSeqReference::findReference(extendedTypeNum(DaxYear)));

        DAXTesting.DaxYear=numberSeq1.num();

        DAXTesting.insert();

    }

    else if(dAXTestingLoc.DaxYear=='2020'&& dAXTestingLoc.Action==NoYes::Yes)

        {

            numberSeq2 = NumberSeq::newGetNum(NumberSeqReference::findReference(extendedTypeNum(NewYear)));

            DAXTesting.NewYear=numberSeq2.num();

            DAXTesting.insert();

        }


}

Retrieve Name,Address,email for a selected customer in ax2012

  We are going to retrive Name, address and email id for a particuler customer

jus add below select statement to retrive the Customer.

static void Customer(Args _args)

{

   CustTable                    custtable;

   DirPartyTable                dirPartyTable;

   LogisticsPostalAddress       logisticsPostalAddress;

   LogisticsLocation            logisticsLocation;

   LogisticsElectronicAddress   logisticsElectronicAddress;


   while  select custtable

       where custtable.AccountNum == 'DE-001'

        join dirPartyTable

            where dirPartyTable.RecId == custtable.Party

       join logisticsPostalAddress

            where  logisticsPostalAddress.Location == dirPartyTable.PrimaryAddressLocation

// we can use below logisticslocation table also for fetching the records

       //join logisticsLocation

            //where logisticsLocation.RecId==dirPartyTable.PrimaryAddressLocation

       

       ////join logisticsElectronicAddress

            ////where logisticsLocation.RecId==logisticsElectronicAddress.Location


       join logisticsElectronicAddress

          where logisticsElectronicAddress.RecId == dirPartyTable.PrimaryContactEmail

    {

   info(strFmt("%1/--/%2/---/_%3/----/_%4",custtable.AccountNum,dirPartyTable.Name,logisticsPostalAddress.Address,logisticsElectronicAddress.Locator));


    }


    //==================================================================


}

Done /-\

Update finanicail dimensions for a particuler vendor in AX2012

 To update Finanicail dimensions for partculer Vendor....we are going to use some of the tables and classes which are mentioned below.

In Microsoft Dynamics AX 2012 the financial dimensions are stored as a 64bit integer surrogate key in the database. For example, the following financial dimension combination of BusinessUnit = 001, ItemGroup = Service in AX it is represented as 22565424233.

For example im updating FD for vendor us102,

static void DefaultFinancialDim(Args _args)

{

DimensionAttributeValue dimAttrBUValue,dimAtrrCCValue,dimAtrrDepValue,dimAttrIGValue,dimAtrrProjValue; //table

DimensionAttribute dimAttrBU,dimAtrrCC,dimAtrrDep,dimAttrIG,dimAtrrProj;//table

DimensionAttributeValueSetStorage davss;//class

RecId defaultDimension;

VendTable vendTable;


davss = DimensionAttributeValueSetStorage::find(CustTable::find("US-102").DefaultDimension);


dimAttrBU = DimensionAttribute::findByName('BusinessUnit');

dimAtrrCC = DimensionAttribute::findByName('CostCenter');

dimAtrrDep = DimensionAttribute::findByName('Department');

dimAttrIG = DimensionAttribute::findByName('ItemGroup');

dimAtrrProj = DimensionAttribute::findByName('Project');


dimAttrBUValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrBU, "003", false, true);

dimAtrrCCValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrCC, "009", false, true);

dimAtrrDepValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrDep, "024", false, true);

dimAttrIGValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAttrIG, "AudioRM", false, true);

dimAtrrProjValue = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrProj, "000006", false, true);


if(dimAttrBUValue || dimAtrrCCValue ||dimAtrrDepValue || dimAttrIGValue || dimAtrrProjValue)

{

davss.addItem(dimAttrBUValue);

davss.addItem(dimAtrrCCValue);

davss.addItem(dimAtrrDepValue);

davss.addItem(dimAttrIGValue);

davss.addItem(dimAtrrProjValue);

vendTable = vendTable::find("US-102", true);

vendTable.DefaultDimension = davss.save();

vendTable.update();

    info('updated');

}


}