databaseManager.getFoundSetCount returns -1

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

databaseManager.getFoundSetCount returns -1

Postby brenda.forshee » Mon Oct 04, 2021 6:50 pm

Why would databaseManager.getFoundSetCount(fsCashReceipts) return -1 when fsCashReceipts.getSize() returns 200. I know there are over 200 records in this foundset.

Below is the entire chunk of code. After I loadRecords I run databaseManager.getFoundSetCount(fsCashReceipts) and it returns -1. It should be well over 200. fsCashReceipts.getSize() returns 200.

//Cash Receipts (pay_head, pay_line, rec_dist)
var cashReceiptsQuery = datasources.db.picas.pay_head.createSelect();
cashReceiptsQuery.where.add(cashReceiptsQuery.columns.pay_hd_date.le(cutoffAR));

//Do not delete if Cash Received on these receivables after the cutoff date
var payLineQuery = datasources.db.picas.pay_line.createSelect();
payLineQuery.where
.add(payLineQuery.columns.cust_no.eq(cashReceiptsQuery.joins.pay_head_to_pay_line.columns.cust_no))
.add(payLineQuery.columns.rec_inv_no.eq(cashReceiptsQuery.joins.pay_head_to_pay_line.columns.rec_inv_no))
.add(payLineQuery.columns.pay_ln_type.eq(cashReceiptsQuery.joins.pay_head_to_pay_line.columns.pay_ln_type))
.add(payLineQuery.columns.pay_hd_date.gt(cutoffAR));
cashReceiptsQuery.where.add(cashReceiptsQuery.or
.add(cashReceiptsQuery.columns.pay_hd_type.isin([scopes.picasAccountsReceivable.CASHRECEIPTTYPES.PENDING,scopes.picasAccountsReceivable.CASHRECEIPTTYPES.VOIDED]))
.add(cashReceiptsQuery.not(cashReceiptsQuery.exists(payLineQuery))));

//Do not delete if Receivable has a date greater than the cutoff date or if the Receivable is not Paid
var receivableQuery = datasources.db.picas.receivable.createSelect();
receivableQuery.where
.add(receivableQuery.columns.cust_no.eq(cashReceiptsQuery.joins.pay_head_to_pay_line.columns.cust_no))
.add(receivableQuery.columns.rec_inv_no.eq(cashReceiptsQuery.joins.pay_head_to_pay_line.columns.rec_inv_no))
.add(receivableQuery.columns.rec_inv_type.eq(cashReceiptsQuery.joins.pay_head_to_pay_line.columns.pay_ln_type));
receivableQuery.where.add(receivableQuery.or
.add(receivableQuery.columns.rec_inv_date.gt(cutoffAR))
.add(receivableQuery.columns.rec_status.not.eq(scopes.picasAccountsReceivable.INVOICESTATUS.PAID)));
cashReceiptsQuery.where.add(cashReceiptsQuery.not(cashReceiptsQuery.exists(receivableQuery)));

cashReceiptsQuery.result.addPk();
cashReceiptsQuery.result.distinct = true;

var fsCashReceipts = datasources.db.picas.pay_head.getFoundSet();
fsCashReceipts.loadRecords(cashReceiptsQuery);
brenda.forshee
 
Posts: 2
Joined: Mon Oct 04, 2021 6:47 pm

Re: databaseManager.getFoundSetCount returns -1

Postby rgansevles » Fri Nov 05, 2021 11:40 am

Hi Brenda,

Does the logfile show any errors?

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: databaseManager.getFoundSetCount returns -1

Postby sbutler » Fri Nov 05, 2021 4:08 pm

As a side note, loadRecords returns a boolean that should really be checked. If you pass in something that may be invalid, it will run, and not load anything and return false. Probably want something like:

Code: Select all
if(fsCashReceipts.loadRecords(cashReceiptsQuery)){
   databaseManager.getFoundSetCount(fsCashReceipts)
}
Scott Butler
iTech Professionals, Inc.
SAN Partner

Servoy Consulting & Development
Servoy University- Training Videos
Servoy Components- Plugins, Beans, and Web Components
Servoy Guy- Tips & Resources
ServoyForge- Open Source Components
User avatar
sbutler
Servoy Expert
 
Posts: 759
Joined: Sun Jan 08, 2006 7:15 am
Location: Cincinnati, OH


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 4 guests