Page 1 of 1

Auto Lookup show only exact match

Posted: 2015-09-11 18:22
by elemire
Hi Guys,

Been using Appgini for several months now to try and create an inventory management program for my company. Everything is coming along good however I am running into one problem I cant figure out how to solve. We have an autolookup filed and when the user scans a barcode into that field it pulls back the information on the skid, such as product number and case count.

Where I am having a problem is if I have a barcode with the value 10 and one entered with the value 100, when they scan barcode 10 it also pulls back 100 in the drop down menu. Is there any way for me to limit the auto lookup to exact matches only. If they scan barcode 10 I don't want it to pull back 10, 100 and 1000 as well.

Re: Auto Lookup show only exact match

Posted: 2015-09-13 19:01
by a.gneady
Do you have other lookup fields in your application? If not, this would do the trick: Open the generated "ajax_combo.php" in a text editor and find this line:

Code: Select all

$wheres[] = "{$field['parent_caption']} like '%{$search_term}%'";
and modify it to:

Code: Select all

$wheres[] = "{$field['parent_caption']}='{$search_term}'";
Beware that if you have other lookup fields, the above would cause them to return exact matches only.

Re: Auto Lookup show only exact match

Posted: 2015-09-14 13:27
by elemire
Thanks for the code it worked perfectly! And the fast response is much appreciated, is it possible to change the code to have the quick search filed at the top act the same way, return only exact matches?

Re: Auto Lookup show only exact match

Posted: 2015-09-14 14:01
by elemire
I spoke to soon, when I changed like to = and type in a value it returns no results even though the value exist in the lookup table. Should I use ==?

Re: Auto Lookup show only exact match

Posted: 2015-09-15 06:24
by a.gneady
Hmm .. == is not part of SQL syntax and won't work ... maybe this might work:

Code: Select all

$wheres[] = "{$field['parent_caption']} like '{$search_term}'";