Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Wednesday, February 14, 2018

Get cost to complete, Cost at complete in Project WBS in AX 2012

static void AlfasithProjWBSCost(Args _args)
{
    hierarchyTreeTable          hierarchyTreeTablePre;
    smmActivities               smmActivitiesPre;
    psaActivitySetup            psaActivitySetupPre;
    ProjWBSUpdateController     controller;
    while    select hierarchyTreeTablePre  where hierarchyTreeTablePre.HierarchyId  == 'EWIG-00032'
    {
        smmActivitiesPre  = smmActivities::findWithRecId(hierarchyTreeTablePre.RefRecId);
        psaActivitySetupPre = PSAActivitySetup::findActivityNumber(smmActivitiesPre.ActivityNumber);
        controller = new ProjWBSUpdateController(hierarchyTreeTablePre.HierarchyId,
                psaActivitySetupPre.CalendarId,
                null,
                null,
                null,
                null,
                false,
                ProjViewType::CostTrackingView,
                null,
                null,
                true);
        controller.updateOutlineNumbersAndPublishInPreOrder();
        print controller.outlineNumberFor(hierarchyTreeTablePre.ElementNumber);
        //Cost estimnation View
        print controller.actualCostFor(hierarchyTreeTablePre.ElementNumber);
        print controller.costAtCompleteFor(hierarchyTreeTablePre.ElementNumber);
        print controller.plannedCostFor(hierarchyTreeTablePre.ElementNumber);

        /*Total actualCost = controller.actualCostFor(_hierarchyTreeTable.ElementNumber);
        Total costAtComplete = controller.costAtCompleteFor(_hierarchyTreeTable.ElementNumber);
        Total costToCompleteAmount = costAtComplete - actualCost;
        */
    }
    pause;

}

Relation between PSAProjProposalProj with PSAContractLineItems in AX 2012


static void Job80(Args _args)
{
     psaProjProposalProj psaProjProposalProj;
     projOnAccTrans projOnAccTrans;
     projProposalOnAcc projProposalOnAcc;
     psaContractLineItems psaContractLineItems;
     while select psaProjProposalProj where psaProjProposalProj.ProjProposalId == "UDI-000127"//_projProposalJour.ProposalId
            join projOnAccTrans where projOnAccTrans.ProjID == PSAProjProposalProj.ProjId
                                    && projOnAccTrans.TransactionOrigin == ProjOrigin::Prepayment
            join projProposalOnAcc where projProposalOnAcc.TransId == projOnAccTrans.TransId
                                    && projProposalOnAcc.ProposalId == PSAProjProposalProj.ProjProposalId
            join psaContractLineItems
                        where psaContractLineItems.FeeProjId == psaProjProposalProj.ProjId
        {
            info(strFmt("%1",psaContractLineItems.LineValue));
        }
}

SQL code to upate one Legal entity banner to all the legal entity in D365

 Hi, update companyimage set  companyimage.Image  = companyimageA.Image  from  ( select Image from companyimage where dataAreaid = 'USF...