9 Replies Latest reply on Jan 26, 2016 8:34 AM by Annette

    Dynamic portal filter based on radio set global variable

    Stu412

      Title

      Dynamic portal filter based on radio set global variable

      Post

      Hi there

      I've created a portal based on a table where each record has Year against it.  On its own the portal is fine and works as I want.

      If I manually filter the portal by Tablename::Year = 2013, only the 2013 year records show up.  Perfect.

      I have added a radio button set with data based on Tablename::Year (2011,2012,2013) and this goes off to a global field, GF_Year.  Just to make sure that happens, I have even added the global field to the layout I'm working on and sure thing, it changes each time I click the radio set.  Good stuff.

      Now, I'm trying to filter the portal by with the calculation Tablename::Year = GF_Year.  Nada. Nothing.

      I've seen posts around about refreshing, caches and all sorts of other things.  At this stage I just want to keep this portal as light as possible as it's not only me going to be using it.  I've got no scripting on this so far.

      Is there some sort of clear down or refresh I need to include to make it work dynamically?

       

      Thanks

        • 1. Re: Dynamic portal filter based on radio set global variable
          SteveMartino

          Just a one step script, attached to an OnObjectModify script trigger may do the trick:

          Refresh Window [flush cashed join results]

          You could try it manually from the Records Menu at the top.  Change your field, then go Records>Refresh Window.  If it works there it will work as a one line script

          • 2. Re: Dynamic portal filter based on radio set global variable
            Stu412

            Sweeeet, thanks Steve.

            Applied it to the radio selector and it works like a dream :)

            • 3. Re: Dynamic portal filter based on radio set global variable
              philmodjunk

              You can change the field's storage options so that it is not global and just be sure to commit records after each change of the field's value. Note that the OnObjectModify trigger can be set up on your radio button formatted field to either Refresh [flush] or commit records.

              But If you want to keep the field as a global field, you can modify your relationship to be:

              LayoutTable::globalRadioButtonField X PortalTable::Year AND
              //put your current match fields here...

              You can double click the relationship line to open up a dialog where you can add more match field pairs like this and to specify a different operator than the default = operator.

              By including the match field in the relationship but with the X operator, the portal will update without needed Refresh Window [Flush Cached Join Results]--which can really slow things down in cases where there are a lot of records involved.

              • 4. Re: Dynamic portal filter based on radio set global variable
                Stu412

                So here's the kicker!

                I'm intending the portal to be used to add info as well as display it.  Normally you'd just click the empty line at the bottom and add a new row.

                In this case, it's filtered by year.  What would be really clever would be for the year field (which is shown on the portal row) to auto populate when a new record is created.

                Would this be a case of script triggering from the portal (OnObjectModify) to a script which adds the GL_Year variable to a new record on the portal table?  Or is there a much more elegant/uncomplicated way to do this?

                 

                • 5. Re: Dynamic portal filter based on radio set global variable
                  philmodjunk

                  You can set up auto-enter options (calculation) to copy the contents of the global field into the new portal record's corresponding year field.

                  • 6. Re: Dynamic portal filter based on radio set global variable
                    Stu412

                    That's great, always wondered how that works.  One subtle behaviour change is the filter now does not change when you click a different year radio button UNLESS you click out of the portal and then click the new year.  It's almost as if you either need to remove the focus from the portal or reset the global variable?

                    • 7. Re: Dynamic portal filter based on radio set global variable
                      philmodjunk

                      What you are doing commits the record change. I did suggest that you use a script trigger to commit records everytime you modify the radio button field.

                      But why would the radio button field be INSIDE the portal?

                      • 8. Re: Dynamic portal filter based on radio set global variable
                        Stu412

                        The radio field is outside the portal, I think my grammar is to blame here!

                        I also had the refresh but not the commit, thanks :)  

                        • 9. Re: Dynamic portal filter based on radio set global variable
                          Annette

                          Hello.  I'm trying to do something similar and tried to apply this suggestion and it still does not update the filter.  I have set my relationship as follows:

                           

                          (Global field) MainMenu::Filter   X   Reports::Filter (calculation field)   AND

                          (Global field) MainMenu::Name  =  Reports::Therapist (Text Field)

                           

                          I've tried changing the relationship operators between X and = with no effect.  When I don't set the menu fields as globals the filter works fine without the filter relationship.  But I really would like to keep them as global to prevent having to make some other changes if I don't.

                           

                          If I understand your response correctly, I do not have to use refresh / committ as a script trigger if I use the relationships?  Correct?

                           

                          Either way, it's not working when I change the radio button filter field on the menu.