8 Replies Latest reply on Jul 9, 2012 8:25 PM by akliewer99

    Portal Filtering not using my Global Variable

    akliewer99

      Title

      Portal Filtering not using my Global Variable

      Post

      I have a global variable which matches the format, "TableName::FieldName=1" FOLLOWED BY A "REFRESH WINDOW Flush, Flush"

      But still my portals don't reflect my filtered records. It shows all records. When I hard code the above filter, it works just fine. 

      Can anyone tell me what I have forgotten?

      My portal filter calculation dialog box show only the call to the variable $$GlobalVar.

      Thanks to any and all who can help!!

      Arlene Cry
      Frustrated in Sacramento, CA
      USA

        • 1. Re: Portal Filtering not using my Global Variable
          philmodjunk

          So your entire portal filter expression is:

          $$GlobalVar

          You use this script:

          Set Variable [$$GlobalVar ; value: 1 ]
          Refresh Window [Flush cached join results]

          And nothing appears in the portal?

          That should result in all related records appearing in the portal.

          Note: if you modify the portal relationship to be:

          LayoutTable::GlobalField X PortalTable::anyfield AND
          //Put existing match fields here.

          Then you can use the global field (rather than the global variable) in your portal filter expression and it will update when the value in the global field changes without needed to use Refresh [flush] to get the portal to update.

          • 2. Re: Portal Filtering not using my Global Variable
            akliewer99

            Thanks for your reply. To clarify my variable passes the whole text value: "layoutTableName::FieldName = 1" into the portal filter. I want to use a variable so I can easily change the filter requirements on the fly. Are you suggesting that a global field would handle this better?

            God Bless,
            Arlene Smile

            • 3. Re: Portal Filtering not using my Global Variable
              philmodjunk

              I'm not sure I understand the purpose intended for your portal filter. What do you want it to do?

              It's unusual to have a filter expression that does not refer to fields in the portal's table. From what I see here, your expression will either display all related records or no related records depending on the value stored in LayoutTableName::FieldName. If there's a 1 in the field, all related records display, if there is any other value or no value, no records display.

              Using a global field that is included in the relationship and that uses the Cartesian Join operator, eliminates the need for Refresh Window [flush... which can be the cause of unacceptably long delays while the screen refreshes in a number of situations.

              • 4. Re: Portal Filtering not using my Global Variable
                akliewer99

                Sorry, I forgot to talk "exact". My hubby is a programmer and I call him Mr. Exact man, so I should have known. I will try again.

                My portal filter is a global variable of "PortalTableName::PortalFieldName =1". It is a combined text string of two other variables and values. Basically it is a checkbox.

                On my layout I have a tab control with three tabs, and a portal on each tab. One for all records, one for checked records and one for "not checked" records.

                As I tab through the tab control or check/uncheck records I want the portals to "filter" and only show only the proper records. I am using the same global variable for each. I am updating the variable depending on the tab pressed.

                My relationships are all set and working, because when I "hard code" the filter in the portal filter calcuation window, all works as expected.  However once I replace the "hard code" with the global variable, my two portals the checked and the unchecked, act as if there wasn't any portal filter set. They both act like the first one and show all records.

                BTW, my totals for each portal are correct and update as needed. I thought that maybe I had a typo or I wasn't Refreshing the window properly but I have ruled both of those out alread.

                See image for details.

                Any idea are "GREATLY" appreciated. I am hitting my head against a brick wall on this one.

                Arlene

                • 5. Re: Portal Filtering not using my Global Variable
                  akliewer99

                  Pictures are worth a thousand words. First screen shot that works! . . . . .

                  • 6. Re: Portal Filtering not using my Global Variable
                    akliewer99

                    Next this screen shows what doesn't NOT WORK and the reason for this whole post. My question is "Why not?"

                    Isn't this the whole idea behind the use of Global variables, to set portal filters on the fly, so we dynamicallly set different filters for different senarios, without having to hard code each and every portal.

                    Sincerely! Thanks for your time,

                    Arlene :)

                    • 7. Re: Portal Filtering not using my Global Variable
                      philmodjunk

                      It doesn't work because you can't put an expression into a variable and expect FileMaker to evaluate it as an expression. All FileMaker knows is that there's some text in the variable. Nothing you've done will tell FileMaker to evaluated it as an expression.

                      Evalulate ( $$PortalFilter )

                      would do that.

                      Sorry, I forgot to talk "exact". My hubby is a programmer and I call him Mr. Exact man, so I should have known. I will try again.

                      My portal filter is a global variable of "PortalTableName::PortalFieldName =1". It is a combined text string of two other variables and values. Basically it is a checkbox.

                      That's worth a few chuckles! Database development and programming is an Exacting process! The details matter. You are dealing with a "idiot savante" machine that will do exactly what you tell it to do, even if that isn't what you want it to do.

                      Point of fact, your text in quotes is not made of two other variables. It refers to a table occurrence name and a Field separated by the :: required for correct syntax in FileMaker expressions.

                      Are you perhaps planning on a series of check box values, each for a different expression? That's a creative approach, but may create portal refresh issues that might be avoidable via a different approach that does not require using the evaluate function.

                      • 8. Re: Portal Filtering not using my Global Variable
                        akliewer99

                        Well you done it to me again. . .

                        I didn't show you step before, which is the actual command to  "Set Variable: $$portalFilter Value: $$portalTableName & "::" & $portalFieldName & "=1"

                        The "exactness" of this business can be exasperating at times.

                        Thanks for your patience and for your help!

                        Your previous suggestion worked great and was exactly what I wanted!!!!!

                        Arlene  Cool
                        Super Happy in Sacramento, CA
                        USA