Get product variant in AX 2012 (X++)
Product variants are setup for product master to distinguish between
the same product with respect to size,
colors etc. For example, Bi-Cycle
is the product master and its size
and color can be different which are
its variant.
Product
variant can be seen from:
Product information management >
Common > Released product
Select any
item and click on Released product
variants.
These
variants can be fetched using following code through X++.
Using Query Build Datasource:
Query query = new
Query();
QueryBuildDataSource qbds, qbdsDim;
QueryRun qr;
InventDim InventDim;
ItemId itemId = "10001";
qbds = query.addDataSource(tableNum(InventDimCombination));
qbdsDim = qbds.addDataSource(tableNum(InventDim));
qbdsDim.relations(true);
qbds.addRange(fieldNum(InventDimCombination,
ItemId)).value(SysQuery::value(itemId));
qr = new
QueryRun(query);
while(qr.next())
{
InventDim = qr.get(TableNum(InventDim));
Info(strfmt("Color/HardRev: %1,Program/Size: %2",
InventDim.InventColorId, InventDim.inventSizeId));
InventDim.InventColorId, InventDim.inventSizeId));
}
Using in-line query:
InventDim InventDim;
InventDimcombination InventDimcombination ;
ItemId itemId = "10001";
InventDimcombination InventDimcombination ;
ItemId itemId = "10001";
Select InventDim Join InventDimCombination
where InventDimcombination.InventDim ==
InventDim.InventDim
&& InventDimCombination.ItemId == itemId;
if(InventDim)
{
Info(strfmt("Color/HardRev:
%1,Program/Size: %2",
InventDim.InventColorId, InventDim.inventSizeId));
InventDim.InventColorId, InventDim.inventSizeId));
}
Comments
Post a Comment