How to go to a specific portal row

The requirement:   In a portal, you need to be able to highlight a given record, and ensure that the portal row is visible.  (For example, a portal contains 20 records, but displays only 3.  You know which record you’re interested in, and you have the id of the record stashed in a global field, but the record may be out of sight when you display the portal.)

I devised a functional, but clunky, way of achieving this, then asked for advice on the Filemaker Technet.  I got 2 really good suggestions.  The first, from David Jondreau, suggested this:

portal_row_highlight1

So, the portal shows sessions (SSN) within a programme (PGM), and the id of the session that we’re interested in is held in the global field PGM::CURRENTSESSIONID.  The loop just goes through the portal rows until it hits that record.  “Go to portal row” ensures that it’s highlighted and visible.

The second suggestion, from Mike Beargie, uses a custom function called “ListIndex” (available from Brian Dunning’s site).  It’s a really concise one-liner:

portal_row_highlight2

The ListIndex CF just finds the position of the global id within the list of related SSN rec ids, and goes to that portal row, all in one script step.  Really neat, but, as Mike pointed out, it relies on the portal not being filtered.

Advertisements

10 Comments on “How to go to a specific portal row”

  1. Kirk R says:

    This makes sure the selected portal row (I use a background field with conditional formatting on a set global vs. a record ID to provide the highlight that also runs the script) show up on the middle of a 15 row portal when selected. The jumping around takes care of the fact the selected row, by default, does not end up in the middle of the portal.

    Set Variable [ $PRow_ID; Value:Get (ActivePortalRowNumber) ]

    Go to Portal Row
    [
    Case
    (
    $PRow_ID 6 ; $Prow_ID +5
    )
    ]
    [ Select; No dialog ]

    Go to Portal Row [ $PRow_ID ] [ Select; No dialog ]

    • Dave says:

      Hello Kirk,

      That sound interesting, and thanks for sharing, but I don’t understand how it works. Could you explain a bit more, especially the Case statement?

      Thanks,

      Dave.

  2. […] How to go to a specific portal row | A Filemaker Miscellany. […]

  3. Watchara Yarnu says:

    Reblogged this on Watchara Yarnu.

  4. CR says:

    Sorry to bring this old subject up, but I just can’t seem to get this function/thing to work…

    Could anyone please elaborate this one for me?

    I don’t get the “Exit Loop If” script step.. Elaborate please..

    Best regards.

  5. CR says:

    Could someone please elaborate the “Exit Loop If” script step?
    I’m somehow lost on this one and how you pull off, so the client always end up on and ready to type in a text field, in the newly created Record?

  6. Matt Leering says:

    I understand that this is an old thread, but I wanted to chime in seeing as there have been some developments in recent releases of FM that help tackle this problem. One way that I now handle it is by putting a summary field into every one of my tables. The summary field basically just does a “List of” the table’s primary key. Once you’ve got something like that available to you, it doesn’t matter if the portal is sorted or filtered. 😉

  7. Matt Leering says:

    @CR — That script step, “Exit Loop If” should really only be used inside of a loop. Typically you will specify the criteria for when to exit the loop inside this step. In some cases, I find myself just using “1” as its criteria though, that way it will ALWAYS exit when it hits that step. If you specify anything else, then it will be a conditional test to see if it should exit the loop.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s