function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sony PSPSony PSP 

Wild card on searching via Text box

Hi folks

please help me, how to I search on textbox via wild card?

ex. is a textbox and I input *h* it should display all wildcards of h, it is needed to use * in textbox for wildcards since in my method below is already a wildcard string query which should be done on textbox instead.

 if(accname != '')
        {
            String strQuery = 'Select Id, FirstName, LastName, '+
                'Account.Name,Account.ShippingCountry,  '+
                'From Contact where Account.Name like \'%'+accname+'%\'';
            
            lstContact =  Database.query(strQuery);
        }
Amit GhadageAmit Ghadage
HI Sony PSP,
If I am not wrong you have input tag something like this
 <apex:inputText value="{!accname}" id="theTextInput"/>
then replace your code snipped with this.
if(accname != '')
        {

String tempAccName =  accname.Substring(1,accname.length() - 1);
             if(tempAccName.length() > 0)
{
             String strQuery = 'Select Id, FirstName, LastName, '+
                'Account.Name,Account.ShippingCountry,  '+
                'From Contact where Account.Name like \'%'+tempAccName+'%\'';
            
            lstContact =  Database.query(strQuery);
}

            
        }

Best Regards,
Amit Ghadage
 
Sony PSPSony PSP
yes, but i need to use the * in textbox so it would return all fields