How to add Records to include option on report dialog in D365FO. Some times user want to apply the filter from UI. That time we need to use Records to include option.
- In Report -- data set properties -- Dynamic Filters (set as True)
- Need to create static query.
- That query we need to call from DP class.
- After that Need to write logic in controller class.
Controller class:
public class new MyReportController extends SrsReportRunController{
public static void main(Args args) { MyReportController controller = new new MyReportController(); controller.parmReportName(ssrsReportStr(MyReport, Report)); controller.parmArgs(args); if(args && args.dataset() == tableNum(MyTable)) { MyTable myTable = _args.record(); Query query;// Get Contract //controller.getDataContractObject()//// for sys operation //controller.parmReportContract().parmRdpContract() // For Report query = controller.getFirstQuery();// get the query from dp class query.dataSourceTable(tableNum(MyTable)).clearRanges(); query.dataSourceTable(tableNum(MyTable)).addRange(fieldNum(MyTable, Id)).value(queryValue(myTable.Id)); query.dataSourceTable(tableNum(MyTable)).addRange(fieldNum(MyTable, Status)).value(queryValue(MyTable.Status)); } controller.startOperation(); } }--------------------------------or--------------------------------------------public class new MyReportController extends SrsReportRunController { public void prePromptModifyContract() { //add a range in the report query SrsReportHelper::addParameterValueRangeToQuery(this.getFirstQuery(), tableNum(Mytable), fieldNum(Mytable, RecId), SysQuery::value(this.parmArgs().record().RecId)); } } ------------------------------------------------------------------------------- public void runReport(){ myContract contract; queryRun queryRun = new queryRun(this.getFirstQuery()); int i = 1; contract = this.parmReportContract().parmRdpContract(); contract.intialize(); while (queryRun.next()) { CompanyInfo companyInfo = queryRun.GetNo(1); switch (i) { case 1 : contract.parmcompany1(companyInfo.NameAlias); break; case 2 : contract.parmcompany2(companyInfo.NameAlias); break; case 3 : contract.parmcompany3(companyInfo.NameAlias); break; case 4 : contract.parmcompany4(companyInfo.NameAlias); break; case 5 : contract.parmcompany5(companyInfo.NameAlias); break; } i++; } super(); }
Dp class:
[ SrsReportQueryAttribute(queryStr(TestQuery)),// This line we need to add SrsReportParameterAttribute(classStr(TestContract)) ] class TestDP extends SRSReportDataProviderBase { TestTmp testTmp; public void processReport() { TestQuery testQuery = this.parmQuery();// get the query queryRun queryRun = new queryRun(testQuery)); while(queryRun.next()) { } } }
Keep Daxing!!
No comments:
Post a Comment