Monday 7 May 2018

Financial Dimension update for Project (or) Costcenter,businessUnit, Department in AX 2012

static void Na_ProjContract(Args _args)
{
    DimensionAttributeValue                        dimAtrrProjValue;
    DimensionAttribute                                 dimAtrrProj;
    DimensionAttributeValueSetStorage       davss;
    RecId                                                        defaultDimension;
    VendTable                                                 vendtable;
    container                                                   defaultdimension1;
    ProjTable                                                   projTable,projTable1;
    ProjFundingSource                                   projFundingSource;
    ProjInvoiceTable                                       projInvoiceTable;
    int                                                              updatecount;

    try
    {
        select projFundingSource  where projFundingSource.ContractId =="Airtel Raf";
        if(projFundingSource.ContractId)
        {
                davss = DimensionAttributeValueSetStorage::find(projTable::find("Pro-000173").DefaultDimension);
                dimAtrrProj       = DimensionAttribute::findByName('Project');
                dimAtrrProjValue  = DimensionAttributeValue::findByDimensionAttributeAndValue(dimAtrrProj, "Pro-000173", false, true);

                if(dimAtrrProjValue)
                {
                    davss.addItem(dimAtrrProjValue);
                    ttsBegin;
                    projFundingSource.DefaultDimension = davss.save();
                    projFundingSource.selectForUpdate(true);
                    projFundingSource.doUpdate();
                    ttsCommit;
                }
        }
    }
    catch(Exception::Error)
    {
        info(strFmt("%1", projFundingSource.ContractId));
    }
     info("Record Updated Successfully");
}

No comments:

Post a Comment