Jump to content

HOW TO: Lookup Portal Record Count


jaboda

This topic is 1703 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I was looking for an easy way to get a record count of a portal and couldn't see how to do it anywhere.
Luckily I found a workaround to do it and thought I'd share.

  1. Select Insert | Other Symbol.
  2. Select FoundCount.
  3. Move the new merge field into a portal row.
  4. Hide the merge field by setting 'Hide object when' to True.
  5. Give the merge field a name, for example 'PortalCount'.

Now you can use the following calculation to find the total row count for the portal:

GetLayoutObjectAttribute ( "PortalCount" ; "content" )

Obviously you can change 'PortalCount' to whatever you like.

If there's an easier (and less hacky) way to do this please let me know.

Link to comment
Share on other sites

Is your portal filtered? If not, the problem becomes "how to count related records" and can be solved by a calculation field in the parent table =

Count ( ChildTable::Matchfield )

or by defining a summary field in the child table and placing it on the layout of parent.

If the portal is filtered, you can place the summary field in a one-row portal that is filtered using the same filtering expression.

Only if the portal is filtered AND you need to use the count of shown records in a further calculation, you would need to use the GetLayoutObjectAttribute() function. But in such case it might be more appropriate to filter the relationship rather than the portal - IOW, work purely at the data level.

 

Edited by comment
Link to comment
Share on other sites

Yes the portal is filtered.

Using GetLayoutObjectAttribute() allows me to not put a summary field in the table structure so I think is cleaner.

Link to comment
Share on other sites

I get your point but your suggestion would require a second Portal and an entry in the table structure.

My technique only requires an additional field in the existing portal...

Unfortunately FileMaker doesn't support Queries, which would be the neatest solution.

Link to comment
Share on other sites

20 minutes ago, jaboda said:

your suggestion would require a second Portal and an entry in the table structure.

I made several suggestions. You need a second portal only if you want to display the filtered count (and display it only once). If you need it for further calculations, you should not be using a portal to get it.

 

25 minutes ago, jaboda said:

Unfortunately FileMaker doesn't support Queries

Not sure what you mean by "Queries". Filemaker certainly does support (a subset of) SQL queries. Whether that would be "the neatest solution" depends on the situation; replicating an existing relationship using SQL is not very appealing.

Link to comment
Share on other sites

2 minutes ago, comment said:

Not sure what you mean by "Queries". Filemaker certainly does support (a subset of) SQL queries. Whether that would be "the neatest solution" depends on the situation; replicating an existing relationship using SQL is not very appealing.

I'm referring to Queries (such as in MS Access) or Views (in MySQL) which provide a layer between the table structure and the forms/reports. FileMaker puts the equivalent in the table structure.

In my experience FileMaker's implementation of SQL is extremely slow and only useful for certain applications. In this case it's much better to use FileMaker relationships.

Link to comment
Share on other sites

This topic is 1703 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.