3 Replies Latest reply on Apr 21, 2014 8:41 AM by philmodjunk

    Getting Portal to Auto-Select Correct Row

    AdamQuintero

      Title

      Getting Portal to Auto-Select Correct Row

      Post

           I have the primary key for a portal table and it's layout parent table stored in global variables $$parentKey and $$portalKey

           The two tables are related, and the portal is filtered as:

           PatternCount(PortalTable::parentKey ; $$parentKey) > 0

           I want to script the OnLayoutEnter trigger such that the highlighted portal row is automatically aligned with the value of $$portalKey.

           My script goes like this:

           Go to Object["portal"]

           Go to Portal Row[Select;First]

           Loop

                If[PortalTable::portalKey ~= $$portalKey]

                     Go to Portal Row[Select; Next; Exit after last]

                Else

                     Exit Loop If PortalTable::portalKey = $$portalKey]

                     Go to Portal Row[Select; Next; Exit after last]

                End If

           End Loop

           What I am getting is the last row of the portal is always highlighted, and it does not highlight the row with value $$portalKey for field PortalTable::portalKey.

           I hope I explained this properly, I am thinking perhaps there may be something wrong with the script's loop?

            

        • 1. Re: Getting Portal to Auto-Select Correct Row
          philmodjunk

               Why do you need the portal filter? You appear to be filtering for the value used to define portal relationship and thus it is not needed.

               in this step:

               If[PortalTable::portalKey ~= $$portalKey]

               Do you really mean that your script reads as:

               If[PortalTable::portalKey ≠ $$portalKey]

               While I can see ways to simplify the script, I don't see any obvious errors other than the odd ~= notation. Have you confirmed that $$portalKey is being assigned the correct value?

               As a test, you can run this script in FileMaker Advanced's script debugger with the data viewer open to watch the values change. Or if you do not have advanced, you might insert a show custom dialog step at the beginning of the loop and set it to display both $$portalKey and PortalTable::portalKey to check on these values.

               A simplified looping script:

               Go to Object["portal"]

               Go to Portal Row[Select;First]

               Loop

                         Exit Loop If PortalTable::portalKey = $$portalKey]

                         Go to Portal Row[Select; Next; Exit after last]

               End Loop

          • 2. Re: Getting Portal to Auto-Select Correct Row
            AdamQuintero

                 I do have Filemaker Pro 13 Advanced, and I ran the debugging test you suggested PhilModJunk.

                 I discovered that during the evaluation step:

                  Exit Loop If PortalTable::portalKey = $$portalKey]

            The values for those terms are in fact equal, but the loop is not being terminated. Perhaps I oversimplified my example. I am trying to use script parameters for those two values where the code for the exit loop step reads:

            Exit Loop If GetValue(Get(ScriptParameter); 1) = GetValue(Get(ScriptParameter); 2)]

            and the parameters for the script read:

            List(PortalTable::portalKey; $$portalKey)

            Possibly this method of defining script parameters could be causing the Exit Loop If script step to not evaluate the terms correctly? If so, Is there a correct way to define these script parameters?

            • 3. Re: Getting Portal to Auto-Select Correct Row
              philmodjunk
                   

              Exit Loop If GetValue(Get(ScriptParameter); 1) = GetValue(Get(ScriptParameter); 2)]

              these two values are passed as script parameters. They will not change when your script loops through the portal rows as no part of this expression checks the value of a field in the current portal row.