You need to sign in to do that
Don't have an account?
Girbson Bijou 8
Search Multiple Fields Criteria Visualforce
I need to search data in a visualforce with criteria from multiple field.
The field which will be used as Critieria are:
Purpose__c : Picklist
Condition__c : Picklist
Prod__c : Text
UM__c: Picklist
Container__c: Text
the code below allow me to set criteria for one field. Help me to improve it.
The field which will be used as Critieria are:
Purpose__c : Picklist
Condition__c : Picklist
Prod__c : Text
UM__c: Picklist
Container__c: Text
the code below allow me to set criteria for one field. Help me to improve it.
public with sharing class InventorySearchController { public list <Articles_Containers__c> inventoryItem {get;set;} public string searchstring {get;set;} public InventorySearchController( ) { } public void search(){ string searchquery= 'select Name , Prod__c, UM__c, Container__c, Number__c, On_Hand__c, Pending__c, Available__c, Purpose__c, Condition__c, Age__c, Comments__c FROM Articles_Containers__c WHERE Prod__c like \'%'+searchstring+'%\' AND On_Hand__c >0 AND IsOpened__c = 1 Limit 50000'; inventoryItem= Database.query(searchquery); } public void clear(){ inventoryItem.clear(); } } // VF <apex:page Controller="InventorySearchController" Sidebar="False"> <apex:form > <apex:inputText value="{!searchstring}" label="Input"/> <apex:commandButton value="Search records" action="{!search}"/> <apex:commandButton value="Clear records" action="{!clear}"/> <apex:pageBlock title="Search Result"> <apex:pageblockTable value="{!inventoryItem}" var="a"> <apex:column value="{!a.Name}"/> <apex:column value="{!a.Prod__c}"/> <apex:column value="{!a.UM__c}"/> <apex:column value="{!a.Container__c}"/> <apex:column value="{!a.Number__c}"/> <apex:column value="{!a.On_Hand__c}"/> <apex:column value="{!a.Pending__c}"/> <apex:column value="{!a.Available__c}"/> <apex:column value="{!a.Purpose__c}"/> <apex:column value="{!a.Condition__c}"/> <apex:column value="{!a.Age__c}"/> <apex:column value="{!a.Comments__c}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
Sorry for this issue you are facing.
May I suggest you please refer to below link from the success community which might help.
- https://success.salesforce.com/ideaview?id=08730000000BrrqAAC
Please let us know if this helps.Thanks,
Nagendra