Hi Experts,
Can anyone help me to spot the mistake in the below query range expression. I need to filter the records with transtype == payment & Last settlevoucher is empty.
public void init()
{
QueryBuildDataSource qbds;
QueryBuildRange qbr;
super();
qbds = this.query().dataSourceTable(tableNum(VendTrans));
qbr = qbds.addRange(fieldNum(VendTrans,LastSettleVoucher));
qbr = qbds.addRange(fieldNum(VendTrans,TransType));
qbr.value(strFmt('((LastSettleVoucher == "%1") && (TransType == %2))',
queryValue(""),
queryValue(any2int(LedgerTransType::Payment))));
qbr.status(RangeStatus::Hidden);
}
Hi,
You can try the solution mentioned by Ergun or try the below snippet.
Just remove the "" from %1.
qbr = qbds.addRange(fieldNum(VendTrans,LastSettleVoucher)); qbr = qbds.addRange(fieldNum(VendTrans,TransType)); qbr.value(strFmt('((LastSettleVoucher == %1) && (TransType == %2))', queryValue(""), queryValue(any2int(LedgerTransType::Payment))));
You don't need to get value with %1 for empty string. As a matter of fact, there is no need for you to use Expressions. If you give range values to the fields like below, such errors will not occur.
Expressions are mostly used to write "or" clauses between multiple fields and create more complex structures.
QueryBuildDataSource qbds; QueryBuildRange qbrSettle,qbrTransType; super(); qbds = this.query().dataSourceTable(tableNum(VendTrans)); qbrSettle = qbds.addRange(fieldNum(VendTrans,LastSettleVoucher)); qbrSettle.value(SysQuery::valueEmptyString()); qbrTransType = qbds.addRange(fieldNum(VendTrans,TransType)); qbrTransType.value(sysquery::value(LedgerTransType::Payment));
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156