Hi guys, I have a requirement to fetch the record to include filtered values from the report dialog.
I need to show those values in the report footer.
Code :
Users can apply filters from the filter screen, and if any new tables are joined or new fields are added. To get those values I have used a query filter.
str value; Query query; QueryFilter qf; query = qr.query();// getting query from query run. int cnt = query.queryFilterCount(); // Fetching data from query if any new tables are joined or new Fileds are added for (int ds =1; ds<= cnt; ds++) { qf = query.queryFilter(ds); if(qf.value()) { value += strFmt('%1 : %2', qf.field(), qf.value()); } }
The below code is to fetch data from the standard query.
str value; Query query; QueryBuildDataSource qbds; QueryBuildRange qbr; int totalDS, totalRanges; query = qr.query();// getting query from query run. totalDS = query.dataSourceCount(); // Used to fectch data from the standard view query for (int ds =1; ds<= totalDS; ds++) { qbds = query.dataSourceNo(ds); totalRanges = qbds.rangeCount(); for (int r =1; r<= totalRanges; r++) { qbr = qbds.range(r); if (qbr.value()) { // Way 1 : value += strFmt('%1 : %2', qbr.prompt(), qbr.value()); // Way2 : TableId tableId = qbds.table();//tableName2Id(qbds.AOTname()); DictTable dictTable = new SysDictTable(tableId); str fieldname = qbr.AOTname(); if(qbr.value()) { MiscParameters += strFmt('%1 : %2 ', dictTable.fieldObject(fieldName2Id(tableId, qbr.fieldName())).label(), qbr.value()); } // Way3 : // Direct Field FieldId fieldId = qbr.field(); if(qbr.value()) { MiscParameters += strFmt('%1 : %2 ', dictTable.fieldObject(fieldId).label(), qbr.value()); } // Way4 : str value = strFmt('%1', qbr.value()); Map miscParametersMap = new Map(Types::String, Types::String);// Write this line at out side of loop if (value) { if (miscParametersMap.exists(qbr.prompt())) { container con = str2con(miscParametersMap.lookup(qbr.prompt()), ',' , false); if (!conFind(con, value)) { con += value; } miscParametersMap.insert(qbr.prompt(), con2Str(con)); } else { miscParametersMap.insert(qbr.prompt(), value); } } if (miscParametersMap.elements()) { MapEnumerator mapEnumerator = miscParametersMap.getEnumerator(); while (mapEnumerator.moveNext()) { value += (strfmt("%1 : %2 ", mapEnumerator.currentKey(), mapEnumerator.currentValue())); } } } } }
Keep Daxing!!