Relationship count

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.

Hi Morley,

You should still be able to get a related count without displaying a portal or tabpanel for the related records using :

num_records = parent_to_child.getSize()

Hope this helps
Harry

Perfect! Huzzah!! Thanks Harry.

Still a great answer :)

But what if there are more then 60 related records, if I am correct relationname.getSize() doesn’t count further then 60.

Regards,

Peter

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. .

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

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… ;-)

I did not realise that it would only pull in 60 records - the updated step has improved the situation..

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. .

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?