Searching on multiple fields

Questions related to customising nuBuilder Forte with JavaScript or PHP.

Re: Searching on multiple fields

Unread postby kev1n » Wed Apr 28, 2021 4:04 am

Use global Hash Cookies (3rd paramer true)

From a previous reply:
viewtopic.php?f=20&t=11002#p24092
kev1n
nuBuilder Team
 
Posts: 2012
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: Searching on multiple fields

Unread postby icoso » Wed Apr 28, 2021 4:17 am

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?
icoso
 
Posts: 181
Joined: Mon Feb 08, 2021 7:39 am
nuBuilder Version: 4.5

Re: Searching on multiple fields

Unread postby kev1n » Wed Apr 28, 2021 4:22 am

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
kev1n
nuBuilder Team
 
Posts: 2012
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: Searching on multiple fields

Unread postby icoso » Wed Apr 28, 2021 9:35 am

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?
icoso
 
Posts: 181
Joined: Mon Feb 08, 2021 7:39 am
nuBuilder Version: 4.5

Re: Searching on multiple fields

Unread postby kev1n » Wed Apr 28, 2021 1:05 pm

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
kev1n
nuBuilder Team
 
Posts: 2012
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Previous

Return to Custom Code

Who is online

Users browsing this forum: No registered users and 2 guests

cron