Counting number of filtered portal rows
Is there a "get" function or some other function that will tell me the count of filtered portal rows (in other words, the number of records found in a filtered search that show in a portal)?
Since portal rows are really related records couldn't you simply do a found count of related records?
Or . . . and I'm not a computer right now, couldn't you Go to portal row (last) and Get the portal row number?
Define a "count of" summary field in the portal's table and specify a field to "count" that is never empty of data--such as a primary key field.
Duplicate your portal but use portal set up to convert the copy to a single row portal. Put this "count of" summary field inside this single row portal. You can change the color or line width of the portal's border to make the portal invisible so that the summary field just looks like any other field on your layout when viewed in browse mode.
PhilMod - I have done the trick you noted on the layout; what I am trying to do is write a script so that if no filtered records are found (ie the number of filtered records are zero in the portal), I want to have a dialog box show noting no records found for the portal filter. Is there a function for a script to show zero records found for the portal search?
It is the "filtering" that masks what you are doing from Summary Functions.
Alternate method to "filtering" is creating a New table of Occurence with more than one Logic key. Example:
pkClientID>-------<fkClientD create a gZero global numeric field valued at 0.
Draw a second Relationship connection line on that new TO from say Balance field to gZero and set the logic operator to ">" instead of "=".
That would create a "filtered" like found set of all Clients whose account Balance would be Positve. Use the Relationship graphs to do an "auto find"
Jim is on the track I would take here. The problem with the summary in a filtered portal trick is that the value is not one that we can "get at" via a script step or calculation field.
On the other hand, Rick's suggestion of go to portal row [last], get ( activeportalrownumber ) might just work as well.
This is how I did it:
In the main table create a field for count. Make it a calculation with:
If ( maintable::field1 = portaltable::field1; Count ( portaltable::field1 ) )
field1 is the field that relates the 2 tables.
The main table count field can be added anywhere on the main table layout, not in the portal area.
You can get at the number in a calculation if you use the GetLayoutObjectAttribute function, using attribute "content" for the summary field in your one row portal. Can't see that this has been suggested by anyone else.
johngodfrey wrote:This is how I did it:In the main table create a field for count. Make it a calculation with: If ( maintable::field1 = portaltable::field1; Count ( portaltable::field1 ) )
You can simply create a calc field in the related table, defined as
Get ( FoundCount )
Be sure to make it unstored. It will work in any parent table, displaying the related count.
Or use a summary field Count of: primary key, which has the added benefit that you can use it for design in sub-summary parts, and programmatically with GetSummary( ).
Won't return the correct count if the portal is filtered and the filter omits some related records. Count will ignore the filter action.
Just to round out the possible options, executeSQL( ) could be used with count to get this value if you set it up to replicate the relationship and the filter.
Or create the summary field in the child records. When you place this inside a copy of the filtered portal (one row only) the value will be correct. Since the two portals are identical (in the filter), no need to do more than this.
If you need the value in another calculation, that is another kettle of fish!
Sent from miPhone
Yep, that was posted in one of the original responses.
Retrieving data ...