Tuesday, December 28, 2021

Filter records in form in D365fo

Hi guys, Today we see how to filter the records in form using X++.

  • If it's a new form directly write the below code.
  •  If it's a standard form. create extension class.
Here we have 2 ways. Follow anyone.

Way 1:

    public QueryBuildRange qbr;//declare this variable globally. public void init()// dataSource init method { super(); qbr = this.query().dataSourceTable(tableNum(InventSite)).addRange(
                                                        fieldNum(InventSite, IsActive)); } public void executeQuery()// dataSource { FormRun formRun = element; if (formRun.args().menuItemName() == menuItemDisplayStr(InventSite)) { qbr.value(queryValue(NoYes::Yes)); } next executeQuery(); 

} 


Way 2:

    public void executeQuery()// dataSource { FormRun formRun = element; if (formRun.args().menuItemName() == menuItemDisplayStr(InventSite)) { this.initializeQueryFromType(); } next executeQuery(); } public void initializeQueryFromType() { QueryBuildDataSource qbDataSource; ; qbDataSource = this.query().dataSourceTable(tableNum(InventSite)); qbDataSource.clearDynalinks(); qbDataSource.addRange(fieldNum(InventSite,                                              isActive)).value(SysQuery::value(NoYes::Yes));

}

Keep Daxing!!

No comments:

Post a Comment