Sunday, May 28, 2017

Adding new fields in On Hand Inventory form ax 2012 R2/R3

// Adding new fields in On Hand Inventory form ax 2012 R2/R3
//Create one View to link with inventTable
//Example - Inventory unit, purchase unit, Product name
Invent Table
 -> Inner Join (EcoResProduct)
  -> Inner Join (EcoResProductTransalation)
 -> Inner Join(InventTableModule as Invent)
 -> Inner Join(InventTableModule as Purchase)
Drag fields which want to display in on hand form and then item id field.
//Form
//InventOnHandItem
//DataSources - InventSum
//Method - ExecuteQuery
Code
//element.inventDimSetupObject().modifyQuery(inventSum_DS,inventDim_DS);//Commented by Sangeeth
    //Added by sangeeth
    element.inventDimSetupObject().modifyQuery(inventSum_DS,inventDim_DS
                        ,InventDetailView_DS);
    //End Code
Super();
//Class
Class->InventDimCtrl_Frm_OnHand
Method-> modifyQuery
Create new optional argument in ModifyQuery method
Code
public void modifyQuery(
    FormDataSource _inventSum_DS,
    FormDataSource _inventDim_DS,
    //Added by Sangeeth
    FormDataSource  _InventDetail_DS = null
    //End Code
    )
{
QueryBuildDataSource    qbsInventDetailLookup;//Added by Sangeeth
code logic:
in ModifyQuery Method at last write below code
//Added by Sangeeth
    if(_InventDetail_DS != null)
    {
        qbsInventDetailLookup = query.dataSourceName(_InventDetail_DS.name());
        qbr = SysQuery::findOrCreateRange(qbsInventDetailLookup, fieldnum(InventDetailView, LanguageId));
        qbr.value(queryValue(CompanyInfo::languageId()));
        qbsInventDetailLookup.addGroupByField(fieldNum(InventDetailView, Name));
        qbsInventDetailLookup.addGroupByField(fieldNum(InventDetailView,InventUnit));
        qbsInventDetailLookup.addGroupByField(fieldNum(InventDetailView,PurchUnit));
        qbsSum = _InventDetail_DS.query().datasourceTable(tablenum(InventTable));
        qbsSum.addGroupByField(fieldNum(InventTable,ItemId));
        qbsSum.addGroupByField(fieldNum(InventTable,Product));
    }
    //End Code

No comments:

Post a Comment

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