4 Replies Latest reply on Apr 2, 2013 8:11 AM by philmodjunk

    Portal filtering oddities.

    argasoft

      Title

      Portal filtering oddities.

      Post

           Hi!

           I have a table addresses with relationship to addresses_X via addresses::id_addresses X addresses_X::id_addresses. TO is addresses.

           On different formats (invoice, offer, store items, etc) via script I bring recall a popup to have a list of names to catch id_addresses to establish a relationship.

           The popoup is a format with just a portal that shows name and city. Format is stated to give records from addresses and portal the ones from addresses_X.

           I want to filter them with a local variable ($port_filter) depending on if I need suppliers or a clients. Of course there is a field (type) in addresses for each record with one of the following values:
           - client
           - supplier
           - both

           In the portal setup I have the filter addresses_X::type <> $port_filter (its value is set via script and can be "client" if I need a supplier and viceversa). Through a button on the popup-format I change ascending or descending order.

           Now to the odds:
           - sometimes at first load after launching FM just the suppliers are listed if asked to
           - if, on another format, I do not want to have suppliers (i.e. just "client" or "both") it's ok   but
           - returning to a "just suppliers" filtering, all are listed   although
            
      - all parametres in the script are ok
             - the value of $port_filter changes via script accordingly to my request (checked with Data Viewer)

           Hope again it's clear enough.

           TIA

           Arnaldo


            

        • 1. Re: Portal filtering oddities.
          raybaudi

          "the value of $port_filter changes via script accordingly to my request (checked with Data Viewer)"

               ... but will be empty at the end of the script.

               Try to use a global variable ( $$port_filter )

          • 2. Re: Portal filtering oddities.
            philmodjunk

                 Another approach may be to set up a global field, instead of a variable for sport_filter and refer to this field instead of a variable in your filter expression. Then modify your relationship to be:

            addresses::Sport_Filter X addresses_X::useAnyFieldHere

                 By including the filter field in the relationship along with the X operator, changes to Sport_Filter will automatically update what is shown in the filtered portal. If you don't include the field in the relationship in this way, you may have to use the script step: Refresh Window [Flush Cached Join Results] to get the portal to update and this can result in undesirable delays waiting for your window to fully update.

            • 3. Re: Portal filtering oddities.
              argasoft

                   Thanks for replies.

                   @raybaudi

                   I do not exit the script that sets value of $port_linebefore loading popup-format and set value [] is before loading the format and with Data Viewer I see it's value is correct when it loads unfiltered portal.

                    

                   @PhilModJunk

                   Global field:
                   - I create it in the addresses main table
                   - set its value via script (like for $port_filter)

                   Is this correct?

                   I'll check the scripts and portal set-up once again to see if something has been overseen.

                   Thanks for the hints.

                   Arnaldo

                   PS (OT) I do not find how to declare a problem as solved in the forum. Where is it?
                    

              • 4. Re: Portal filtering oddities.
                philmodjunk

                     It would be defined in addresses with the storage, field options set to specify global storage. Global storage is not strictly necessary but is often a good idea--especially if you have more than one person using your database at the same time.

                     You can use set field to set the value of this field or you can put the field on your layout and format it with a value list. Either method works.

                     You can select any post here, even your own as the "best answer". But once selected, you can't change this setting so make sure you have this working before selecting a post as "best answer".