Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Searching on multiple fields

Questions related to customising nuBuilder Forte with JavaScript or PHP.
kev1n
nuBuilder Team
Posts: 4299
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Searching on multiple fields

Unread post by kev1n »

Use global Hash Cookies (3rd paramer true)

From a previous reply:
https://forums.nubuilder.cloud/viewtopic. ... 002#p24092
icoso
Posts: 181
Joined: Sun Feb 07, 2021 11:09 pm
Been thanked: 1 time

Re: Searching on multiple fields

Unread post by icoso »

That's what Im trying to do. I don't understand why its not working?

Do I do it like this: nuSetProperty('SQLSEARCH', sql, true);

Why then am I able to access the FRM_lastname variable in the called form, but not FRM_lname?
kev1n
nuBuilder Team
Posts: 4299
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Searching on multiple fields

Unread post by kev1n »

Should this Hash Cookie only be available on client-side (JavaScript)? Then try setting a variable with window.yourvariable = 'something' and retrieve it again with
window.yourvariable
icoso
Posts: 181
Joined: Sun Feb 07, 2021 11:09 pm
Been thanked: 1 time

Re: Searching on multiple fields

Unread post by icoso »

I got this to work using the global HKs. I do have another question. What I've done has an interesting result. I use my Launch from that I have my search fields on to build an SQL statement and save it in a global HK FRM_srchsqlform. Then on my browse/edit form I added this to the browse screen SQL :
AND
IF('#FRM_srchsqlform#' = 'Y', #FRM_search#, 1)

This results in adding my long SQL statement for all the fields that I have on my launch form to my browse/edit form SQL. ie:

Code: Select all

if (lastname != "") {
   if (sql != "") {
      sql = sql + " AND TaxCustomers.cust_lastname LIKE '" + lastname +"%'";
 } else { 
      sql = sql + "TaxCustomers.cust_lastname LIKE '" + lastname +"%'";
}
}
What happens is that if I get a lot of results after my search form, I can then type a value in the browse screen search field and click search and it will hold that variable data from the #FRM_srchsqlform#' and add to it the CONVERT statements that the normal browse/edit form adds to the SQL, ie:

Code: Select all

CONVERT(cust_firstname USING utf8) LIKE "%john%" OR CONVERT(cust_address USING utf8) LIKE "%john%" OR CONVERT(tax_billdate USING utf8) LIKE "%john%" OR CONVERT(tax_taxyear USING utf8) LIKE "%john%" OR CONVERT(tax_preparer USING utf8) LIKE "%john%"
and further limits the results.

The question I have, Im not sure if I want that or not. Its a neat feature, but could be confusing for a typical end-user. So how then could I wipe out the variable #FRM_srchsqlform# after those original results are displayed? I suppose I could use the BE code to clear it. Thinking that if the user then clicks a record in the browse list to edit that record, I'd want to force them to search for something new once they exit the edit form, right?
kev1n
nuBuilder Team
Posts: 4299
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Searching on multiple fields

Unread post by kev1n »

By setting a global empty Hash Cookie with nuSetProperty()?
Or depending on your SQL a condition that always results in true like WHERE 1=1
Post Reply