A filter expression for "last 7 days" as I understand it:
TimeSheet::Date >= Get ( CurrentDate ) - 7
So how would we write if else statement in portal filter. for example " if " "last 7 days" do something "else" do something else
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.
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
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.
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.
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.
Client chooser.fmp12.zip 72.1 K