Forums: Creating User Defined Session variable to filter List Pages - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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

#1 User is offline   hahle001 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 3
  • Joined: 08-July 08

Posted 30 October 2012 - 10:52 AM

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.

#2 User is offline   timnorvel 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 273
  • Joined: 21-September 07
  • Gender:Male
  • Location:Minnesota, USA

Posted 17 July 2013 - 05:18 PM

Funny, I just did this same thing this week. It took me 2 weeks to come to this idea. I have to remember to check this tips and tricks forum more often!

Great tip. It works great!

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users