Page 1 of 1

Relationship count

PostPosted: Tue Sep 28, 2004 4:14 pm
by Morley
Is it possible to get a record count for a relationship without actually loading that relationship?

I'm in a situation in which I just want to know the count, not actually go there. I definitely don't want to disturb the current foundset. FMP's Count function would be perfect in this situation.

PostPosted: Tue Sep 28, 2004 4:27 pm
by Harry Catharell
Hi Morley,

You should still be able to get a related count without displaying a portal or tabpanel for the related records using :
Code: Select all
num_records = parent_to_child.getSize()


Hope this helps
Harry

PostPosted: Tue Sep 28, 2004 4:45 pm
by Morley
Perfect! Huzzah!! Thanks Harry.

Re: Relationship count

PostPosted: Wed Jan 04, 2012 9:14 pm
by itgenetics
Still a great answer :)

Re: Relationship count

PostPosted: Thu Jan 05, 2012 9:31 am
by Peter de Groot
But what if there are more then 60 related records, if I am correct relationname.getSize() doesn't count further then 60.

Regards,

Peter

Re: Relationship count

PostPosted: Thu Jan 05, 2012 10:22 am
by ROCLASI
The answer to Morley is from 2004 so this is a very very old thread.

But yes, getSize() will only show the amount of PK's loaded. If you really want to know the real foundset size you should use databaseManager.getFoundsetCount(foundset) which is the equivalent of SELECT count(pk) etc. .

Re: Relationship count

PostPosted: Thu Jan 05, 2012 11:09 am
by Peter de Groot
I know it's an old post, but I replied because:

Re: Relationship count

by itgenetics ยป 04 Jan 2012 21:14
Still a great answer :)


Regards,

Peter

Re: Relationship count

PostPosted: Thu Jan 05, 2012 1:04 pm
by Harjo
And to be more specific, by the touching the relation this way, WILL trigger a query to load the related data first, also when you only need the count....... ;-)

Re: Relationship count

PostPosted: Fri Jan 06, 2012 4:32 pm
by itgenetics
I did not realise that it would only pull in 60 records - the updated step has improved the situation..

Re: Relationship count

PostPosted: Fri Jan 06, 2012 4:37 pm
by itgenetics
ROCLASI wrote:The answer to Morley is from 2004 so this is a very very old thread.

But yes, getSize() will only show the amount of PK's loaded. If you really want to know the real foundset size you should use databaseManager.getFoundsetCount(foundset) which is the equivalent of SELECT count(pk) etc. .


So how would this work in a calculation?

return databaseManager.getFoundsetCount(prd_to_bom.bom_pk)

prd_to_bom is relationship between the product database and mom is a bill of materials database

or am I off the mark?