Moved from title by moderator:
On this while query run loop, it is fetching all the given project id in dialog but loop running only for first ID and then loop stops and throwing only first record output. Could anyone help ?
if(dialog.run())
{
projid = dlgfld1.value();
fromdate = dlgfld2.value();
toDate = dlgfld3.value();
query = new Query();
qbds = query.addDataSource(tablenum(ProjTransPosting));
qbr = qbds.addRange(fieldnum(ProjTransPosting, ProjId)); qbds.addGroupByField(fieldNum(ProjTransPosting,projid));
qbr.value(projid);
qbr = qbds.addRange(fieldnum(ProjTransPosting, LedgerTransdate)); qbr.value(SysQuery::range(fromdate, toDate));
queryrun = new QueryRun(query);
while (queryrun.next())
{
projTransPosting = queryrun.get(tableNum(ProjTransPosting));
projectid = projTransPosting.ProjId; info(projectid);
select sum(AmountMST) from ProjTransPosting
where ProjTransPosting.ProjId == projectid &&
//ProjTransPosting.LedgerTransDate >= fromdate &&
//ProjTransPosting.LedgerTransDate <= toDate &&
ProjTransPosting.PostingType == LedgerPostingType::ProjCost;
totalcost = ProjTransPosting.AmountMst;
select sum(AmountMst) from ProjTransPosting
where ProjTransPosting.ProjId == projectid &&
//ProjTransPosting.LedgerTransDate >= fromdate &&
//ProjTransPosting.LedgerTransDate <= toDate &&
ProjTransPosting.costSales == ProjCostSales:: sales;
totalrevenue = abs(ProjTransPosting.AmountMst);
info(strFmt("Total Cost for the project '%1' is %2 ",projectid,totalcost));
info(strFmt("Total Revenue for the project '%1' is %2 ",projectid,totalrevenue));
}