This topic is locked

How do I capture value entered into Search Field

5/31/2014 4:33:12 PM
ASPRunnerPro General questions
acaruson author

If anyone has any advice or tips for capturing the values entered by the user in the search field...and the values chosen by the user during an "Advanced Search"...so I can record them in the database, I would be eternally grateful. My ultimate goal, is to be able to record the details of each user search so the search patterns and search terms can be examined for trends, issues, etc.
Thanks to anyone who can help in advance!

Sergey Kornilov admin 6/3/2014
acaruson author 6/4/2014



Check this article:

http://xlinesoft.com/asprunnerpro/docs/print_search_parameters_on_list_page.htm'>http://xlinesoft.com/asprunnerpro/docs/print_search_parameters_on_list_page.htm
The second example should do it.


Thank you. This was helpful, because I can now capture what was entered in this field and post it to a log table using:
[indent]doAssignmentByRef searchClauseObj,unserialize(Session(CSmartStr(strTableName) & "_advsearch"))

searchClauseObj.var_where(searchClauseObj.sessionPrefix & "_simpleSrch")[/indent]
..and an INSERT query using CustomQuery(sql)
I tried using the solution outlined in http://xlinesoft.com/asprunnerpro/docs/print_search_parameters_on_list_page.htm'>http://xlinesoft.com/asprunnerpro/docs/print_search_parameters_on_list_page.htm for the Advanced Search form...however, no matter what I try, there seems to be no easy way to capture the value of each field in the Advanced Search form when the user selects "Search". If I could, I would use CustomQuery(sql) to post the values of each of these fields in the database when the user selects search.


The hard part is, I know ASPRunner at some point is passing a variable for each one of these fields to a SQL query as part of the search process. It's these variables I want...just once...each time a search is executed. Essentially, I want to be able to record what people are searching for.

Sergey Kornilov admin 6/4/2014

Same article, first example.
Try to use the suggested code as is to see if it works and then adjust it for your needs.

acaruson author 6/4/2014



Same article, first example.
Try to use the suggested code as is to see if it works and then adjust it for your needs.


I have. I'm able to capture "some" of the variables, however, not reliably.
If a field isn't used, no data is returned. So it makes it difficult to parse the results and put different fields in different portions of a log table using an INSERT query.

Also, it doesn't pull the values WHEN the search button is selected. It only works when you return to the page.

ASPRunner is such an awesome program. Truly one if the most powerful tools. I find it hard to believe its so difficult to pass the value of a field to a variable for use in a query when "search" is selected.

Sergey Kornilov admin 6/5/2014

It's hard to understand why would you need to capture values of the field that people are NOT searching for. It is designed to search for what user has selected only.

acaruson author 6/5/2014



It's hard to understand why would you need to capture values of the field that people are NOT searching for. It is designed to search for what user has selected only.


A fair question. In this example there are 9 "fields". This may be a reflection of the limits of my skills or imagination, however, if I'm trying to capture the value of any of the fields used...and include that value in an INSERT query...where each field in the form is represented in a log table with an independent field...the INSERT query will require I have a value for each field. In other words, the INSERT query will be waiting for 9 values to put in the log table when someone hits "search". The method shown in the example will return values only for those fields used. As it "loops" through, I can't figure out how to populate a variable for the empty fields (nothing works) (If var1 = "" then var1 = "not used") Doesn't work.
To make matters worse, I can't get the method to work at the moment the "search" query (button) is executed.
In the example form shown, "Department" is represented by {$Department_editcontrol}. It's the value the user is entering in this field...and is being passed to the SQL query that I want to intercept and INSERT into a log file the moment "search" is executed.

Sergey Kornilov admin 6/5/2014

Post the code that you currently use and we'll see how it can be adjusted. What version of ASPRunnerPro do you use?