Hi guys, Today we see how to filter Product and ProductMaster details separately in ax 2012 using X++.
check this class you can find the code in below method.
\Classes\EcoResProductListPageInteraction\initializeQuery
Run the below job:
static void filterProductdetails(Args _args)
{
ProdParameters prodParameters;
Query query = new Query();
QueryBuildDataSource qbds1,qbds2;
QueryBuildRange queryBuildRange;
QueryBuildLink queryBuildLink;
Range range;
QueryRun queryrun;
EcoResProduct ecoResProduct;
InventTable inventTable;
//select firstOnly prodParameters;
qbds1 = query.addDataSource(tablenum(InventTable));
//queryBuildRange = qbds1.addRange(fieldnum(InventTable, Product));
//queryBuildRange.value(prodParameters.Product);
// Add the second datasource to the first data source
qbds2 = qbds1.addDataSource(tablenum(EcoResProduct));
queryBuildLink = qbds2.addLink(fieldnum(InventTable, product),fieldnum(EcoResProduct, RecId));
// Get only ProductMaster details
//range = queryValue(DictTable::getRelationTypeFromTableName(tableStr(EcoResProductMaster)));
// Get only Product details
range = queryValue(DictTable::getRelationTypeFromTableName(tableStr(EcoResDistinctProduct)));
// Get both Product and ProductMaster details
//range = queryValue(DictTable::getRelationTypeFromTableName(tableStr(EcoResProductMaster)));
//range = queryRangeConcat(range, DictTable::getRelationTypeFromTableName(tableStr(EcoResDistinctProduct)));
query.dataSourceName(queryDataSourceStr(EcoResProductListPage, EcoResProduct));
queryBuildRange = qbds2.addRange(fieldNum(EcoResProduct, InstanceRelationType));
queryBuildRange.value(range);
queryrun = new queryrun(query);
while(queryrun.next())
{
inventTable = queryrun.get(tablenum(InventTable));
ecoResProduct = queryrun.get(tablenum(EcoResProduct));
info(strfmt("%1 - %2 ",inventTable.ItemId,ecoResProduct.productSubtype())); // to check your result
}
}
OutPut:
Keep Daxing!!
No comments:
Post a Comment