Sunday, 29 November 2015

Ware house Phone number

static void warehousetelephonenumber(Args _args)
{
    str                                 Warehouse;
    LogisticsElectronicAddress          LogisticsElectronicAddress;
    LogisticsLocation                   LogisticsLocation;
    InventLocationLogisticsLocation     InventLocationLogisticsLocation;
    InventLocation                      InventLocation;
    ;
    Warehouse   = "11";
    InventLocation = InventLocation::find(Warehouse);
    Select firstOnly InventLocationLogisticsLocation
        where InventLocationLogisticsLocation.InventLocation    == InventLocation.RecId;
    if (InventLocationLogisticsLocation)
    {
        select firstOnly LogisticsLocation
            where LogisticsLocation.ParentLocation      == InventLocationLogisticsLocation.Location
            && LogisticsLocation.IsPostalAddress        == NoYes::No;
        if (LogisticsLocation)
        {
            Select firstOnly LogisticsElectronicAddress
                where LogisticsElectronicAddress.Location    == LogisticsLocation.RecId;
            if (LogisticsElectronicAddress)
            {
                info(strFmt("%1",   LogisticsElectronicAddress.Locator));          
            }
        }
    } 
}

===============================================================

logisticsElectronicAddressLocator getElectronicAddressByType(LogisticsElectronicAddressMethodType _type)
{
    InventLocationLogisticsLocation     InventLocLogLocation;
    LogisticsLocation                   logisticsLocation;
    logisticsLocation                   contactInfoLogLoc;
    LogisticsElectronicAddress          logisticsElectronicAddress;
    LogisticsPostalAddress              logisticsPostalAddress;
    ;
    while select firstOnly * from logisticsLocation
            where logisticsLocation.IsPostalAddress     == NoYes::Yes
        exists join InventLocLogLocation
            where InventLocLogLocation.Location         == logisticsLocation.RecId
               && InventLocLogLocation.InventLocation   == this.RecId
               && InventLocLogLocation.IsPrimary        == NoYes::Yes
        exists join LogisticsPostalAddress
            where LogisticsPostalAddress.Location       == logisticsLocation.RecId
               && logisticsPostalAddress.ValidFrom      <= DateTimeUtil::utcNow()
               && logisticsPostalAddress.ValidTo        >  DateTimeUtil::utcNow()
        exists join contactInfoLogLoc
            where contactInfoLogLoc.ParentLocation      == logisticsLocation.RecId
        exists join LogisticsElectronicAddress
            where LogisticsElectronicAddress.Location   == contactInfoLogLoc.RecId
               && logisticsElectronicAddress.Type       == _type
    {
        return logisticsElectronicAddress.Locator;
    }

    return '';
}

Thursday, 26 November 2015

How to add a method for the click event of a button placed on action pane of a List Page

Setting the DisplayTarget property of the button to the value "Client" will hide the button if used from Enterprise Portal and will enable you to override the clicked method. If you not plan to use the list page in EP then go ahead.
Otherwise you will have to put your code in the target form init or class main method.

Wednesday, 25 November 2015

Automatic PO Confirmation and Packingslip

static void PostPOPackingSlip(Args _args)
{
        PurchFormLetter  purchFormLetter;
        PurchTable       purchTable;
    purchTable  = purchTable::find('000048');
    if (purchTable.DocumentState != VersioningDocumentState::Confirmed)
                {
                    purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
                    purchFormLetter.update(purchTable, "def1");
                }

                purchTable.reread();

                if (purchTable.DocumentState == VersioningDocumentState::Confirmed)
                {
                    purchFormLetter = PurchFormLetter::construct(DocumentStatus::PackingSlip);
                    purchFormLetter.update(purchTable,"123",systemDateGet(), PurchUpdate::All, AccountOrder::None,false,false);

                }

info("jobcompleted");

}

Thursday, 19 November 2015

AutomaticSOPackingSlip

static void AutomaticSOPackingSlip(Args _args)
{
    SalesTable  salestbl;
    SalesLine                   salesline;
    SalesFormLetter_PickingList salesFormLetter;

    salestbl    =   SalesTable::find('000184');
    while select salesline  where salesline.SalesId ==  salestbl.SalesId
    {
        salesline.selectForUpdate(true);
         ttsBegin;
            salesline.SalesDeliverNow   =   salesline.QtyOrdered;
            salesline.update();
            ttsCommit;

    }
    salesFormLetter = SalesFormLetter_PickingList::newPickingList();
    salesFormLetter.transDate(systemDateGet());

    salesFormLetter.update(salestbl,
                            systemdateget(),
                            SalesUpdate::All,
                            AccountOrder::None,
                            NoYes::No,
                            NoYes::No);

}

Wednesday, 18 November 2015

Get the String values from String separated by Delimiter


Requirement : To separate values from String with Pipe Delimited Values.

static void ValueFromStringSepdeli(Args _args)
{
    citInboundLineData x;
    container c;
    SalesShippingDate shipdate;
    int i;

    x= "SOPack"+"|"+"SO1"+"|"+"PR1"+"|"+"item1"+"|"+"10"+"|"+"25/5/2015"+"|"+"tn1";
    c = str2con(x,"|");
    //conview(c);
     for (i=1; i <= conLen(c); i++)
    {
        info (strFmt("container value %1 is %2", i, conPeek(c, i)));
    }
    shipdate    =   str2Date(conPeek(c,6),123);
    info(strFmt("%1",shipdate));
}

static void Job9(Args _args)
{
    citInboundLineData x;
    container c,toc;
    SalesShippingDate shipdate;
    int i;
     x= "SOPack"+","+"000185"+","+"PR1"+","+"T0004"+","+"10"+","+"12/31/2015"+","+"tn1";
    //toc =   con2Str(x, "|");
    toc = str2con(x,",");
    x = con2str(toc,"|");
    info(x);
    c=  str2con(x,"|");
    conview(c);
 
}

Monday, 16 November 2015

AX 2009 Reports

http://www.slideshare.net/magive249/report-microsoft-dynamics-ax

Through Report Wizard :
http://blog.rahulsharma.in/2009/12/reporting-capabilities-of-ms-dynamics_14.html

A requirement of Creating report , with Grouping / then get top 10 Highest Amount value sorting in Descending.

This is done by using Temp tables - Insert - filter values in to temp, the process to get it sort and insert.  Then send only 10 records through fetch method on to the report.

Use Programmable Section:

I got the requirement to Get details and below get the total Amounts  section .  Total amount section ( should be run only for the 10 Highest Amount Value , this all can be done in Fetch method.








public boolean fetch()
{
    boolean ret     =   false;
    q = qrun.query();

// Loop all the Query and in to Details temp table .
    while(qrun.next())
    {
        purchlineRec    =   qrun.get(tablenum(Purchline));
        inventtblRec    =   qrun.get(tablenum(InventTable));

        this.RelInventTbl(purchlineRec);
        table.ItemId        =   purchlineRec.ItemId;
        table.ItemName      =   purchlineRec.itemName();
        table.PODate        =   PurchTable::find(table.PurchId).createdDate;
        table.PurchId       =   purchlineRec.PurchId;
        table.QtyOrdered    =   purchlineRec.QtyOrdered;
        table.PurchPrice    =   purchlineRec.PurchPrice;
        table.DeliveryDate  =   purchlineRec.DeliveryDate;
        table.LineAmount    =   purchlineRec.LineAmount;
        table.VendName      =   VendTable::find(purchlineRec.VendAccount,false).Name;
        table.insert();
    }
// Insert – only one record per Item in to total temp table – Insert in to Table with Total Sum Amount etc ( fields required in Total Section)

   while select table
    {
        instbl = null;
       select instbl    where instbl.ItemId ==  table.ItemId;
       if(!instbl)
       {
        select sum(LineAmount),sum(QtyOrdered)from tablegrp where tablegrp.itemid == table.itemid;
        instbl.ItemId       =   table.ItemId;
        instbl.TotLineAmt   =   tablegrp.LineAmount;
        instbl.TotPurchQty    =   tablegrp.QtyOrdered;
        instbl.insert();
        }
    }
// Looping total Temp table , order by TotLine Amt – and get detail transactions for Details Temp table  
   while select * from instbl order by TotLineAmt desc where instbl.ItemId  != ""
   {
        while select * from table
            where table.ItemId  ==  instbl.ItemId
            {
                TotLineamt          =   instbl.TotLineAmt;
                TotPurchQty       =   instbl.TotPurchQty;

                //ttscommit;
                if(i <10)
                 element.send(table);
                else
                    break;

            }
            if(i >9)
                break;
             if (TotLineamt)
                {
                    element.execute(1); // Calling Programmable section only at required Part.

                }
              i++;

   }
    ret =   true;
    return ret;
}