Page 1 of 1

Filter override

PostPosted: Thu Apr 15, 2010 5:29 am
by sal88
We have some calendar entries that we want to be on display no matter what the filter is set to. Or at least for the all day events to act in this manner.

What is the best way of achieving this?

Thx

PostPosted: Thu Apr 15, 2010 6:21 am
by John Sindelar
Cool idea. Since Filters are basically "finds", you'll want to script find that always includes these special records. But, you only need this find to run if other filters have been applied. So, here is how to do it.

Edit the script "Apply Filter to Found Set" and find the Exit Loop If script step. Right BEFORE that, add two lines:

Set Field [ SampleEvents::YourField ; Your Criteria ]
New Record Request

Create one pair of lines like this for every criteria you wish exempted from filters.

That's it.

Now if you want to always include all day events (to exempt them from the filters), you'll need to add a calc to your events table. Call it EventIsALLDay and make the calculation equal to isempty ( YourTimeStartDField ). Then in the Set Field mentioned above, set this field to 1 like this:

Set Field [ SampleEvents:: EventIsALLDay ; "1" ]
New Record Request

Enjoy!

PostPosted: Thu Apr 15, 2010 9:12 am
by sal88
I think I have done what you said, I want it to always display entires with a blank resource, so I created a calc field to show a "1" when the resource field is blank, but it does not recognise any filters when I do this, here is the code with my bit in bold:

#The following loop tranforms return separated criteria (as you'd find in a checkbox) into separate requests.
Loop
Set Variable [ $c; Value:$c +1 ]
Set Field By Name [ Evaluate ( "$$sc_FilterField" & $sc_FilterNumber ); GetValue ( $$sc_FilterCriteria[$sc_FilterNumber] ;
$c ) ]
If [ $$sc_FilterOmit [ $sc_FilterNumber ] ]
Omit Record
End If
Set Field [ SampleEvents::Resource_Is_Empty; "1" ]
New Record/Request

Exit Loop If [ $c ≥ $sc_FiltersCountOfCriteria ]
New Record/Request
End Loop
Constrain Found Set [ ]
# > > trap for nothing found?


Should the above work?

thx

PostPosted: Thu Apr 15, 2010 9:39 am
by John Sindelar
Looks good except that you should have left the original New Record step there so it should look like this:

#The following loop tranforms return separated criteria (as you'd find in a checkbox) into separate requests.
Loop
Set Variable [ $c; Value:$c +1 ]
Set Field By Name [ Evaluate ( "$$sc_FilterField" & $sc_FilterNumber ); GetValue ( $$sc_FilterCriteria[$sc_FilterNumber] ;
$c ) ]
If [ $$sc_FilterOmit [ $sc_FilterNumber ] ]
Omit Record
End If
New Record/Request
Set Field [ SampleEvents::Resource_Is_Empty; "1" ]
New Record/Request
Exit Loop If [ $c ≥ $sc_FiltersCountOfCriteria ]
New Record/Request
End Loop
Constrain Found Set [ ]
# > > trap for nothing found?

PostPosted: Thu Apr 15, 2010 9:50 am
by sal88
Got it thankyou!