Creating User Defined Session variable to filter List Pages
Handy when you have a lot of menu's you want to filter

Challenge: Create functionality to set and reset a Session Variable in the ASP session

In this example we want to create a Session Variable that holds the Salesman number. The Salesman number is stored in the SALESMAN table (Oracle database).

1. Created two Views: 1. Salesman_Set and 2. Salesman_reset; both connected to table SALESMAN.
2. For both views just selected one field from the SALESMAN table: in this case SALESMAN_NR
3. For both Views selected just one page in the "Pages to build" screen: the Add Page
4. In the "Choose fields to appear on page" screen select the SALESMAN_NR field for the Salesman_Set View and no field for the Salesman_Reset View
5. For the Salesman_Set View: link the SALESMAN table to the SALESMAN_NR In the "Visual editor" screen (Lookup) to see the SALESMAN_NAME in the Add page (list box). For the Salesman_Reset page there is no field so you don't need to do anything here.
6. In the "Event" screen in page "Add-Before record added" implemented the following code:
> * For Salesman_Set:
> Session("Salesman_number") = values("SALESMAN_NR")
> Response.Redirect "menu.asp" (or any other page)
> BeforeAdd = false
> * For Salesman_Reset:
> Session("Salesman_number") = ""
> Response.Redirect "menu.asp" (or any other page)
> BeforeAdd = false

> NOTE: don't forget to remove the line "BeforeAdd = true" at the bottom of the page

7. In the List pages where I want to use the Session variable "Session("Salesman_number")" I implemented the following code:
> if Session("Salesman_number") <> "" then
> strWhereClause = whereAdd(strWhereClause," CIS_SALESMAN_NR = '" & Session("Salesman_number") & "'")
> else
> end if
The above code checks the value of the Session variable "Session("Salesman_number")". If it's empty it shows the List page without a filter applied. If there is a value, then the List page is filtered based on this value (in this example field CIS_SALESMAN_NR)
8. You can change the names of the two menu's in the Menu Builder if you want.

This solution is very handy when you have many menu's where you want to apply the same filter during your session.