AnsweredAssumed Answered

Counting filtered portal records to use in script

Question asked by SteveMartino on Sep 15, 2017
Latest reply on Mar 1, 2019 by Jean-Francois

Hello Forum...welcome back everyone.

I had a question about counting the records in a filtered portal, then using that number in a script.  I seem to be dancing around it but can not get it to work.

In the screenshot you see (circled in red) in the portal, the summary field I added shows the correct number, but in the data viewer it is showing total record count for that table-I assume this is expected behavior.

The goal would be, using the type ahead at the top of the portal, if the user types a word that doesn't contain an item in the portal (the portal will go blank at that point-expected) but I would then like to pop up a dialog asking the user if they would like to create a new (product) record.

I've done this before with a master-detail portal by having the search box both filter the portal and perform a find based on the master table.  But in this case I just have a portal showing Products on the Invoice table (layout) with their own Cartesian relationship to show all Product records.

The end  goal would be to allow a user to select a Product to add to the Line Items of an Invoice.  If no product is available, pop open a small window, user creates a new Product record, and allow scripting to add this to the line items.

Anyway, I'm stumped with how to determine when a filtered portal is empty (no records found or match).

Things I've tried...lots.  But here are some of them:

-Using the same portal filter expression in with an If script step and case statement.  But because the Case evaluates to the first true, it didn't work.

Here's the portal filter expression:


IsEmpty (PRODUCTS_Invoices::gPortal_Sort)


PatternCount (PRODUCTS_Invoices::Category ;PRODUCTS_Invoices::gPortal_Sort ) > 0


PatternCount ( PRODUCTS_Invoices::Brand ; PRODUCTS_Invoices::gPortal_Sort ) > 0


PatternCount ( PRODUCTS_Invoices::Name ; PRODUCTS_Invoices::gPortal_Sort ) > 0


PatternCount ( PRODUCTS_Invoices::Description; PRODUCTS_Invoices::gPortal_Sort ) > 0


-Trying to base the If step off of the summary field in the portal.   As explained earlier, it only returns the total record count for the table.

-I didn't try anything with SQL, only because I've never successful created one on my own that worked (grrr) and believe me I tried.


Any thoughts, or help is always appreciated.




Here's the unfinished script.