Hi, 

in my company we have a new requirement - on ProdJournalTable we need to see records form ProdJournalTable where ProdId field is empty and this ProdJournalTable record has ProdJournalBOM lines with ProdId (on ProdJournalBOM) equal my prod order ID.

Query form ProdJournalTable form is on ProdJournalFormTable class and I change ExecuteDatasourceQueryPre:

if (formRun.args().parm() == identifierStr(Production) && callerProdId)
{
query = new Query();
qbs = query.addDataSource(tableNum(ProdJournalTable));
qbs.name(journalTable_ds.name());
journalTable_ds.query(query);

this.queryAddRange();

//-> my code

//qbs.addRange(fieldNum(ProdJournalTable, ProdId)).value(callerProdId); /ORG
qbr1 = qbs.addRange(fieldNum(ProdJournalTable, ProdId));
qbr1.value(callerProdId);

qbr2 = qbs.addRange(fieldNum(ProdJournalTable, ProdId));
qbr2.value(queryValue(''));

info(qbs.toString());

qbs2 = qbs.addDataSource(tableNum(ProdJournalBOM));
qbs2.addLink(fieldNum(ProdJournalTable, JournalId), fieldNum(ProdJournalBOM, JournalId));
qbs2.joinMode(JoinMode::ExistsJoin);
qbr3 = qbs2.addRange(fieldNum(ProdJournalBOM, ProdId));
qbr3.value(callerProdId);

info(qbs2.toString());

//<-my code
}

And now I see records from PJT where ProdId = my order or ProdId = empty and on PJB ProdId = my order, but now i don't see records with route cards and task cards...

Can You help me?