13 Replies Latest reply on May 25, 2016 11:15 PM by tays01s

    Portal filtering

    tays01s

      I like to filter a portal from 3 parent layout checkbox fields. For each field I'd like an 'all' choice where records would not be filtered for that particular field. Is there a neater way than having a separate 'All/None' choice script triggering the filling/blanking of the checkboxes?

        • 1. Re: Portal filtering
          erolst

          You mean like:

           

          ( IsEmpty ( LayoutTable::gCheckBox1 ) or LayoutTable::gIgnoreCheckBox1 or LayoutTable::checkBox1 = PortalTable::field1 )

           

          and

           

          ( IsEmpty ( LayoutTable::gCheckBox2 ) or LayoutTable::gIgnoreCheckBox2 or LayoutTable::checkBox2 = PortalTable::field2 )

           

          etc.

          • 2. Re: Portal filtering
            tays01s

            Thanks, but I'll need a bit more explanation. Is your suggestion part of an If function script trigger?

            • 3. Re: Portal filtering
              erolst

              You were asking for a portal filter.

              • 4. Re: Portal filtering
                tays01s

                Apologies, yes. I'd just looked at a similar but different issue.

                 

                Back to this and your filter, please could you expand a little on what your 'or' & 'and' syntax are doing?

                • 5. Re: Portal filtering
                  tays01s

                  Pondering a bit more:
                  IsEmpty ( LayoutTable::gCheckBox1 ):                    How do I make 1 item in a checkbox global?

                  or LayoutTable::gIgnoreCheckBox1:                        I assume this is the 'None' box?

                  or LayoutTable::checkBox1 = PortalTable::field1     This refers to the individual choices?

                  • 6. Re: Portal filtering
                    erolst

                    If you want to test on 3 different criteria (or criteria groups), and want to be able to ignore or apply each one individually, you need per group

                     

                    • a field to hold your criterion (or criteria, as with a checkbox)

                    • a switch to ignore this criterion

                     

                    then combine this using Boolean logic; the basic form is:

                     

                    ( apply filter for first criterion: criterionOne IsEmpty or ignoreFirst = true or fieldOne comparison = true )

                    and

                    ( apply filter for second criterion: criterionTwo IsEmpty or ignoreSecond = true or fieldTwo comparison = true )

                    and

                    ( apply filter for third criterion: criterionThree IsEmpty or ignoreThird = true or fieldThree comparison = true )

                     

                    i.e. for a record to be shown, in each group at least one of the sub-expressions must be true.

                     

                    You need to use parentheses because “and” binds more closely than “or”, and you don't want this:

                     

                    criterionOne IsEmpty

                    or

                    ignoreFirst = true

                    or

                    fieldOne comparison = true and criterionTwo IsEmpty

                    or

                    ignoreSecond = true

                    or

                    fieldTwo comparison = true and criterionThree IsEmpty

                    or

                    ignoreThird = true

                    or

                    fieldThree comparison = true

                     

                    btw, if you have checkboxes and want for several values per attribute to be true (e.g. all records where colour is red or green or blue), check out FilterValues().

                    • 7. Re: Portal filtering
                      tays01s

                      I found that this worked well to filter values:

                      Set Field [ Users::Item; Case(
                      Users::Item_all_none = "All";ValueListItems ( Get ( FileName ) ; "Item"); Users::Item_all_none = "None";"" )]

                       

                      I've used a similar setting for each criterion.

                       

                      Oddly there's a problem with the "Item" check/unchecking in that 2 of the 4 fields disappear and don't reappear when unchecked/rechecked. I've tried using an 'on modify' script = Commit, Refresh Window.

                      • 8. Re: Portal filtering
                        erolst

                        tays01s wrote:

                        I found that this worked well to filter values

                        That is a mechanism to set a field to all values of its attached value list, or empty it – but that has per se nothing to do with the logic you need to use that field / its values as a filter …

                        • 9. Re: Portal filtering
                          tays01s

                          True. I tried my above approach with an appropriate relationship. However, I'd still like to understand the filter approach.

                           

                          Concentration on just 1 criterion as an example.

                          ( apply filter for first criterion: criterionOne IsEmpty or ignoreFirst = true or fieldOne comparison = true )

                          If "User::Item_all_none" is my boolean switch and "User::Item" is my checkbox field, how would the filter calculation for just this one criterion go. I'm afraid I don't know how to apply IsEmpty, ignoreFirst and comparison within the filter calc.

                          • 10. Re: Portal filtering
                            erolst

                            tays01s wrote:

                             

                            True. I tried my above approach with an appropriate relationship. However, I'd still like to understand the filter approach.

                             

                            Concentration on just 1 criterion as an example. […] If "User::Item_all_none" is my boolean switch and "User::Item" is my checkbox field, how would the filter calculation for just this one criterion go.

                            I think this is much easier to demonstrate than to explain.

                             

                            Have a look at the attached sample.

                            • 11. Re: Portal filtering
                              tays01s

                              I've little familiarity with the "X" table join. Is the Magic_Key effectively joined to all Object IDs?

                              • 12. Re: Portal filtering
                                erolst

                                tays01s wrote:

                                I've little familiarity with the "X" table join. Is the Magic_Key effectively joined to all Object IDs?

                                 

                                Yes, but it doesn't matter what fields you relate in a Cartesian relationship.

                                 

                                But that is somewhat beside the point in this sample …

                                • 13. Re: Portal filtering
                                  tays01s

                                  Thanks. Took me a while but I think I've managed to apply it to my solution. To others using this, carefully check each script, object and filter line; there are several neat subtleties that make the difference between it working and not.