Showing posts with label Inventory. Show all posts
Showing posts with label Inventory. Show all posts

Monday, February 22, 2021

Block Inventory through code in D365fo


Block Inventory through code in D365fo


 static void inventBlocking(Args _args)

{

   InventBlocking   inventBlocking ;

    InventDim       inventDim;

;

    ttsBegin;

    InventBlocking.initValue();

    inventBlocking.Qty=0.5;

    inventBlocking.ItemId="D0001";

    inventDim.InventSiteId='1';

    inventDim.InventLocationId='11';

    inventBlocking.InventDimId=InventDim::findOrCreate(inventDim).inventDimId;

    inventBlocking.Description='inventory blocking';

    inventBlocking.insert();

    ttsCommit;

    info(strFmt('%1- %2',inventBlocking.Description, inventBlocking.ItemId));

}

Keep Daxing!!

How to De block the Item from Invent Block in D365fo

 Hi guys, Today we see How to De block  the Item from Invent Block in D365fo.


Check below job.

static void deBlock(Args _args)

{

 InventBlocking   inventBlocking ;

    InventDim       inventDim;


    inventDim.InventSiteId='1';

    inventDim.InventLocationId='11';

    inventDim = InventDim::findOrCreate(inventDim);

    

    select inventBlocking join inventDim

        where inventBlocking.ItemId=="Dax Sub 1"

        &&inventBlocking.InventDimId==inventDim.inventDimId

        && inventBlocking.Qty==3;


    ttsBegin;

    if (inventBlocking.BlockingType == InventBlockingType::Manual)

    {

        inventBlocking.selectForUpdate(true);

        inventBlocking.delete();

        info(strFmt('%1','del'));

    }

    ttsCommit;

}

Keep Daxing!!