7 Replies Latest reply on Oct 11, 2016 1:24 AM by muhammad.ikram@contedia.com

    Applying filters on portal records

    muhammad.ikram@contedia.com

      Hello Everyone.

       

      I need help with applying filters to a portal records.

       

      I have activities sheet with date and time. I was trying to search for portal records based on time range. The part I am struggling on is filter activities in "Last 7 days" or "Last 30 days".

       

      I tried using case statements for example if "period selected = "Last 7 Days " than go to table and field, get current date and do - 7. But this case statement does not work.

       

      So how we can apply if/else or case statements in portal to filter records.

       

        • 1. Re: Applying filters on portal records
          philmodjunk

          A filter expression for "last 7 days" as I understand it:

           

          TimeSheet::Date >= Get ( CurrentDate ) - 7

          • 2. Re: Applying filters on portal records
            muhammad.ikram@contedia.com

            Yes Great.

             

            So how would we write if else statement in portal filter. for example " if " "last 7 days" do something "else" do something else

            • 3. Re: Applying filters on portal records
              philipHPG

              If what you want to do is filter by different criteria depending on whether it is in the last 7 days or not, you can use the If function:

               

              If ( TimeSheet::Date >= Get ( CurrentDate ) - 7 ; CriteriaIfWithinLastWeek ; CriteriaIfNotWithinLastWeek )

               

              Or you could use the Case function:

               

              Case ( TimeSheet::Date >= Get ( CurrentDate ) - 7 ; CriteriaIfWithinLastWeek ; AnotherCondition ; CriteriaIfTheOtherConditionMatches ; CriteriaIfTheOtherConditionDoesntMatch )

               

               

              Note that there is a difference between the If statement (which are used in scripts) and the If function (which is used in a calculation, such as the portal filter calculation). Your description seems to indicate some confusion between the two. The If statement (in a script) allows you to "do" different things based on the condition, whereas the If and Case functions return different values based on the conditions.

              • 4. Re: Applying filters on portal records
                muhammad.ikram@contedia.com

                Good explanation. I was actually thinking If statements are similar in scripts and calculation.

                 

                I was actually trying to do filter activities from portal by 2 different ways. One way where user select the time period for example in "Last 7 Days", "Last 30 Days", "Last Quarter" and other way user would select "Date from" and "Date to".

                 

                I was thinking to write "if statement" so if user select "Last 7 days", the portal would display activities from last 7 days. and if user select "last 30 Days" the portal would filter records to last 30 days.

                 

                What would be best way around it.

                 

                Many Thanks in advance

                • 5. Re: Applying filters on portal records
                  philmodjunk

                  if ( YourTable::gFilterOption = "Last 7 Days" ; TimeSheet::Date >= Get ( CurrentDate ) - 7 ; TimeSheet::Date >= Get ( CurrentDate ) - 7 )

                   

                  If you use a global field and the script step is available to you in your version, give the portal an object name and use a script with Refresh Portal to update the portal's display after changing the filter option. If you use a non global field, be sure to commit records after making a change in order to see the filtered portal update.

                  • 6. Re: Applying filters on portal records
                    David Moyer

                    Hi,

                    I didn't realize this until just now ... you can have a global text field with the FM calculation describing your filter.  Then in the portal setup, Filter portal records, use Evaluate ( table::g_PortalFilterCalc ).  If you change the calculation, you need to Refresh the window; but you can change the filter dynamically this way.

                    ... just chiming in.

                    • 7. Re: Applying filters on portal records
                      muhammad.ikram@contedia.com

                      I have attached a sample file. I would like to filter records in portal by 2 search ways. one by selecting time period and other by giving dates. How would I write specify criteria script to search for records.

                       

                      I have tried if and case statements but they don' seem to work.