Tuesday, August 18, 2015

Inventory Item Registration lines Auto in ax 2012

//Inventory Item Registration in Transfer Order lines Auto in ax 2012
//Registering an Item , success only when On hand Avail physical Qty is greater than Zero

static void San_InvTransRegistrationCode(Args _args)
{
    InventTransferTable     transferTable;
    InventTransferLine      transferLine;
    InventTransWMS_Register inventTransWMS_register;
    InventTrans             inventTrans;
    TmpInventTransWMS       tmpInventTransWMS;
    InventDim               inventDim,Dimtmp,inventDimCreate;
    int                     i;
    Name                    size,color,warehouse,wmslocation,site;

    while select transferTable
                where transferTable.InventLocationIdFrom == "<from warehouse number>"   && transferTable.InventLocationIdTo == "<To Warehouse number>"
                            && transferTable.TransferStatus == InventTransferStatus::Shipped
                            //&& transferTable.TransferId =="<Transfer Order id>"
    {
        while select transferLine where transferLine.TransferId == transferTable.TransferId
               //&&  transferLine.ItemId == "<Item number >"
        {
            Dimtmp.clear();
            Dimtmp.InventSizeId = InventDim::find(transferLine.inventDimId).InventSizeId;
            Dimtmp.InventColorId = InventDim::find(transferLine.inventDimId).InventColorId;
            Dimtmp.InventLocationId = transferTable.InventLocationIdTo;
            Dimtmp.wMSLocationId = "Default";
            Dimtmp.InventSiteId = InventDim::find(transferLine.inventDimId).InventSiteId;
            inventDimCreate = inventDim::findOrCreate(Dimtmp);

            ttsBegin;
            inventTrans = InventTrans::findTransId(transferLine.InventTransIdReceive,true);
            if(inventTrans)
            {
                inventTrans.inventDimId = inventDimCreate.InventDimId;
                inventTrans.update();
            }
            ttsCommit;

            inventDim = inventDim::find(inventTrans.inventDimId);
            inventTransWMS_register = inventTransWMS_register::newStandard(tmpInventTransWMS);
            tmpInventTransWMS.clear();
            tmpInventTransWMS.initFromInventTrans(inventTrans);
            tmpInventTransWMS.InventQty = transferLine.QtyShipped;
            tmpInventTransWMS.InventDimId = inventTrans.InventDimId;          
            tmpInventTransWMS.insert();

            inventTransWMS_register.writeTmpInventTransWMS(tmpInventTransWMS,inventTrans,inventTrans.inventDim());
            inventTransWMS_register.updateInvent(transferLine);
  i++;
        }
    }
}

Sunday, August 2, 2015

Hiding form parts in a form

Please use this Code if you want to hide a few parts(Form Parts or Info Parts) in your form

Form --> method --> Run

 PartList        partList;
 int                partListCount,cnt;
 FormRun     factBox;

        partList = new PartList(element);
        cnt = partList.partCount();

        for (partListCount = 1; partListCount <= cnt; partListCount++)
        {
            factBox = partList.getPartById(partListCount);
            switch(factBox.name())
            {
                // Header factboxes:
                case identifierStr(InventOnHandItemCostPart):
                    factBox.design().visible(false);
                    break;
            }
       }

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...