web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Blogs / DAX Beginners / How to: Get Item default in...

How to: Get Item default inventory dimensions

Christian Silva Profile Picture Christian Silva 707

Good afternoon everyone,

Today I would like to share something very useful when creating a production order through code but somehow I wasn’t able to find about it on internet which is ‘How to get an Item default inventory dimensions’.

I have created an Job to show how it works:

static void _GetInventoryDimensions(Args _args)
{
    InventTable                 inventTable = inventTable::find('D0004');
    InventItemOrderSetupType    setupType   = InventItemOrderSetupType::Invent;
    InventDim                   inventDim;
    ;

    // Default Site
    inventDim.InventSiteId = inventTable.inventItemOrderSetupMap(setupType).inventSiteId(inventDim.InventSiteId, inventTable);

    // Default Location
    inventDim.InventLocationId  = inventTable.inventItemOrderSetupMap(setupType,                                                                      <span id="mce_SELREST_start" style="overflow:hidden;line-height:0;">&#65279;</span>InventDim::findOrCreate(inventDim).InventDimId)                                                                    .inventLocationId(inventDim.InventLocationId,                                                                                        inventTable,                                                                                        inventDim.InventSiteId);<span id="mce_SELREST_end" style="overflow:hidden;line-height:0;">&#65279;</span>

    // Default ConfigId
    inventDim.ConfigId = inventTable.StandardConfigId;

    // Find Default Item Dimension
    inventDim = InventDim::findOrCreate(inventDim);

    info(strFmt('Invent Dim. Id: %1', inventDim.inventDimId));
    info(strFmt('Site Id: %1', inventDim.InventSiteId));
    info(strFmt('Warehouse Id: %1', inventDim.InventLocationId));
}

This was originally posted here.

Comments

*This post is locked for comments