Page 3 of 3
Re: Searching on multiple fields
Posted: Tue Apr 27, 2021 8:34 pm
by kev1n
Use global Hash Cookies (3rd paramer true)
From a previous reply:
https://forums.nubuilder.cloud/viewtopic. ... 002#p24092
Re: Searching on multiple fields
Posted: Tue Apr 27, 2021 8:47 pm
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?
Re: Searching on multiple fields
Posted: Tue Apr 27, 2021 8:52 pm
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
Re: Searching on multiple fields
Posted: Wed Apr 28, 2021 2:05 am
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?
Re: Searching on multiple fields
Posted: Wed Apr 28, 2021 5:35 am
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