Wednesday, 23 May 2018



How to find Latest Date in Ax 2012 using X++


d  is a current date;

select maxOf(Aks_ValidateDate) from Aks_MetalPriceList
            where Aks_MetalPriceList.Aks_ValidateDate <= d;
   
info(strFmt("%1",Aks_MetalPriceList.Aks_ValidateDate));




Thanks,
Akshay

Wednesday, 16 May 2018



How to extract Date from utcDateTime in ax 2012 using x++


utcdateTime                 testDonedateTime1,testDonedateTime2;
utcdateTime                 testDonedateTime;
transdate                   tmpDate,tmpDate1 ;

;
testDonedateTime1 = ledgerJournalTable.createdDateTime;

testDonedateTime  = DateTimeUtil::applyTimeZoneOffset(testDonedateTime1, DateTimeUtil::getUserPreferredTimeZone());

 tmpDate = DateTimeUtil::date(testDonedateTime);

info(strfmt("Date -%1"),tmpDate));



Thanks
Akshay

Thursday, 10 May 2018


Route Version Active and approved in ax 2012 using x++



static void Aks_routeVersionApproval(Args _args)
{
RouteTable  routeTable;
    RouteVersion        routeversion;
     RouteApprove                routeApprove;
    RouteVersionApprove         routeVersionApprove;
    RouteVersionActivate        routeVersionActivate;
   
 
while select forUpdate routeversion
    where routeversion.Approved == NoYes::No
    {
       
            if (routeVersion)
            {
                routeVersionApprove = BOMRouteVersionApprove::newRouteVersion(routeVersion);
                routeVersionApprove.parmApproveRoute(true);
                routeVersionApprove.parmRemove(false);
                routeVersionApprove.parmApprover(HcmWorker::userId2Worker("akshaykupra"));//curUserId()));
                routeVersionApprove.run();

                routeVersionActivate = BOMRouteVersionActivate::newRouteVersion(routeVersion);
                routeVersionActivate.run();
            }
       
     
    }
     info("done");
   
   
}


curUserID() is ther approver user id.




Thanks
Akshay