Saturday, July 25, 2015

Enable filter option in Display method Ax 2012

/// To Enable filter option in Display method Ax 2012


public void context()
{
    int             selectedMenu;
    formrun         fr;
    Args            ag;
    Name            strtext;
    querybuilddataSource qb1;
    queryrun    qr;
    query       q;
    PopupMenu menu = new PopupMenu(element.hWnd());
    int a = menu.insertItem('Filter By Field');
    int b = menu.insertItem('Filter By Selection');
    int c = menu.insertItem('Remove Filter');
    ;

    selectedMenu = menu.draw();
    switch (selectedMenu)
    {
    case -1:
            break;
    case a:
            ag = new args('SysformSearch');
            fr = new formrun(ag);
            fr.run();
            fr.wait();
            strtext = fr.design().controlName('FindEdit').valueStr();
            if(strtext)
            {
                q   = TestDisplayLkp_ds.query();
                qb1 = q.dataSourceTable(tablenum(TestDisplayLkp));
                qb1 = qb1.addDataSource(TableNum(InventTable));
                qb1.addLink(FieldNum(TestDisplayLkp,ItemId1),FieldNum(InventTable,ItemId));
                qb1.addRange(FieldNum(InventTable,NameAlias)).value(strtext);
                TestDisplayLkp_ds.query(Q);
                TestDisplayLkp_ds.executeQuery();
            }
            break;

    case b:
            q   = TestDisplayLkp_ds.query();
            qb1 = q.dataSourceTable(tablenum(TestDisplayLkp));
            qb1 = qb1.addDataSource(TableNum(InventTable));
            qb1.addLink(FieldNum(TestDisplayLkp,ItemId1),FieldNum(InventTable,ItemId));
            qb1.addRange(FieldNum(InventTable,NameAlias)).value(strtext);
            TestDisplayLkp_ds.query(Q);
            TestDisplayLkp_ds.executeQuery();
            break;
    case c :
            q   = new Query();
            qb1 = q.addDataSource(tablenum(TestDisplayLkp));
            qb1.clearLinks();
            qb1.clearRanges();
            TestDisplayLkp_ds.query(Q);
            TestDisplayLkp_ds.removeFilter();
            break;

    Default:
            break;
    }

}

Monday, July 20, 2015

Retail AX

Retail Blogs:

http://axretail.blogspot.ae/

http://ax-retail.com/ 

Entity Relationship Diagram in Ax 2012 ( New Creation and Existing ER)

ER Diagram for System Default Table in Ax 2012 for all Modules

https://www.microsoft.com/dynamics/ax/erd/ax2012r2/

And We can also create new ER diagram for our Customize Table (New Functionality) also by using Below Link tutorial

https://www.visual-paradigm.com/tutorials/reverse-ddl.jsp
.bak
.sql

.sql and .bak file to Reverse ddl to make ER in SQL server 2012

Wednesday, July 15, 2015

Inventory Marking Functionality x++ Batch in Ax 2012

// Inventory Marking Functionality in X++ for All Transaction:

 Create New Batch Class , Extends RunBaseBatch

public void InventAutoMarkingRec()
{
    //InventTransOrigin InventTransOrigin,InventTransOriginL;
    InventTrans InventTrans,InventTransL;
    InventTransOriginId receiptInventTransOriginId;
    CostAmountValue CostAmountValue1,CostAmountValue2;

   while select forupdate InventTransOrigin
                    where InventTransOrigin.ReferenceId == ‘Reference Id’
            join InventTrans where InventTransOrigin.RecId == InventTrans.InventTransOrigin
                     && InventTransOrigin.ReferenceCategory == inventtranstype::InventTransaction
                            && InventTrans.StatusReceipt ==StatusReceipt::Purchased
                                //&& (InventTransOrigin.itemid == '9696'||InventTransOrigin.itemid == '9697')
    {
        //qtyToMark = InventTrans.Qty;
       // inventDim        = InventTrans.inventDim();
      while  select forupdate InventTransOriginL
                                where InventTransOriginL.ReferenceId == ‘Reference Id’

                    join InventTransL where InventTransOriginL.RecId == InventTransL.InventTransOrigin
                                && InventTransOriginL.ReferenceCategory == inventtranstype::InventTransaction
                                    && InventTransL.StatusIssue == StatusIssue::Sold
                                        && InventTransL.Qty * -1 == InventTrans.Qty
                                            // && InventTransOrigin.itemid ==InventTransOriginL.itemid
                                            //&& InventTrans.CostAmountPosted == InventTransL.CostAmountPosted *-1
                                            //&& InventTransOrigin.itemid =='1004'
            {
                CostAmountValue1=  InventTrans.CostAmountPosted;
                CostAmountValue2=  InventTransL.CostAmountPosted * -1;
                if(CostAmountValue1 == CostAmountValue2)
                {

                    this.AdremTek_San_InvMarkAuto(InventTransOriginL.InventTransId,InventTransOrigin.InventTransId,InventTrans.Qty);
                    info(strFmt("%1 -Lot Id %2 - Ref Lot %3",InventTransOrigin.ItemId,InventTransOriginL.InventTransId,InventTransOrigin.InventTransId));
                }
            }
     }
}


void Adt_San_InvMarkAuto(InventTransId _issueInventTransId,InventTransId _receiveInventTransId,InventQty _qty)
{
    InventTrans issueInventTrans;
    TmpInventTransMark tmpInventTransMask;
    Map mapMarkNow;
    container con;
    real qty;
    Map mapTmp;
    MapEnumerator mapEnumerator;

    //for Issue Lot Id
    InventTransOriginId issueInventTransOriginId =
        InventTransOrigin::findByInventTransId(_issueInventTransId).RecId;
    //For ReceiptL  Lot Id
    InventTransOriginId receiptInventTransOriginId =
        InventTransOrigin::findByInventTransId(_receiveInventTransId).RecId;
    InventQty qtyToMark = _qty; // Qty Need to Mark

    ttsBegin;

    issueInventTrans = InventTrans::findByInventTransOrigin(issueInventTransOriginId);

    [con, qty] = TmpInventTransMark::packTmpMark(InventTransOrigin::find(issueInventTransOriginId),issueInventTrans.inventDim(),issueInventTrans.Qty);

    mapTmp = Map::create(con);
    mapEnumerator = mapTmp.getEnumerator();
    while (mapEnumerator.moveNext())
    {
        tmpInventTransMask = mapEnumerator.currentValue();

        if (tmpInventTransMask.InventTransOrigin == receiptInventTransOriginId)
        {
            tmpInventTransMask.QtyMarkNow = qtyToMark;
            tmpInventTransMask.QtyRemain -= tmpInventTransMask.QtyMarkNow;
            mapMarkNow = new Map(Types::Int64, Types::Record);
            mapMarkNow.insert(tmpInventTransMask.RecId, tmpInventTransMask);

            TmpInventTransMark::updateTmpMark(
                issueInventTransOriginId,
                issueInventTrans.inventDim(),
                -qtyToMark,
                mapMarkNow.pack());

            break;
        }
    }

    ttsCommit;
}


Copy Markup charges while posting purchase invoice using X++

 Copy Markup charges while posting purchase invoice using X++ Class: Important: Code logic is just for Reference.  New class => Duplicate...