Jump to content
Sign in to follow this  
jaboda

HOW TO: Lookup Portal Record Count

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.

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

As I tried to say earlier, the cleaner solution is not to rely on layout objects for calculations at the data level.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

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