• #15844
    Salesforce | PRANAV PRANAV #679

    How to make multiselect checkboxes in searched results of any Salesforce sObject?

    Hi All,

    How to make multiselect checkboxes in searched results of any Salesforce sobject?

    As in my scenario, there is a search box which searches the user’s entered value and shows the result via search button click. So I want to select multiple results (through checkbox) to use it further. How it can be done help me out.



    Salesforce | Mohit Mohit #401

    Hi Pranav,

    You have to create a Visualforce page to show data and you have to make controller for it to perform operation.

    Here is Visualforce page:-
    <apex:page standardController=”Opportunity” extensions=”OpportunityProductsearch”>
    <apex:form id=”theForm”>
    <apex:pageBlock title=”Search the Product” >
    <apex:inputText value=”{!searchtext}”/>
    <apex:commandButton value=”search” action=”{!search}” />
    <apex:pageMessages />
    <apex:pageBlockSection Title=”List of Product” id=”table” collapsible=”false” rendered = “{!toshow}”>
    <apex:pageBlockTable value=”{!listofproductselected}” var=”p” >
    <apex:column title=”Select” >
    <apex:inputCheckbox value=”{!p.checked}” ></apex:inputcheckbox>
    <apex:column headervalue=”Name” value = “{!p.pro.Name}” />
    <apex:column headervalue=”Product Code” value=”{!p.pro.ProductCode}”/>
    <apex:column headervalue=”Description” value=”{!p.pro.Description}” />
    <apex:commandButton value =”Submit” action =”{!submit}” rendered=”{!toshow}” />
    <apex:pageBlockSection Title=”List of Product in Update” id=”table2″ collapsible=”false” rendered = “{!!toshow}”>
    <apex:pageBlockTable value=”{!showprod}” var=”s” >
    <apex:column headervalue=”Name” >
    <apex:inputField value = “{!s.Name}” />
    <apex:column headervalue=”Product Code”>
    <apex:inputField value=”{!s.ProductCode}”/>
    <apex:column headervalue=”Description”>
    <apex:InputField value=”{!s.Description}” />
    <apex:commandButton value =”save” action =”{!autoupdate}” rendered=”{!!toshow}” />
    <apex:commandButton value =”cancel” action =”{!search}” rendered=”{!!toshow}” />

    and Now the Controller:-
    public with sharing class OpportunityProductsearch {
    public String searchText{get;set;}
    public boolean toshow{get;set;}
    public List<Product2> prod{get;set;}
    public list<ProductWrapper> listofproductselected{get;set;}
    public list<Product2> selectedproduct;
    public list<Product2> showprod{get;set;}

    public class ProductWrapper{
    public Product2 pro{get;set;}
    public Boolean checked{get; set;}
    public ProductWrapper(Product2 p,boolean b){
    pro = p;
    checked = b;
    public OpportunityProductsearch(ApexPages.StandardController con){
    toshow = true;
    prod = new List<Product2>();
    public void search(){
    toshow = true;
    listofproductselected = new list<ProductWrapper>();

    String s = ‘%’+searchText+’%’;
    prod =[select Name,ProductCode,Description,family from Product2 where name like :s ];

    for(Product2 p : prod){
    ProductWrapper pw = new ProductWrapper(p,false);
    public void submit(){
    toshow = false;
    selectedproduct = new list<Product2>();
    for(ProductWrapper p : listofproductselected ){
    if(p.checked == true){
    System.debug(‘the select product to be printed : ‘+selectedproduct);
    showprod = selectedproduct;
    public void autoupdate(){
    update showprod;

Viewing 2 posts - 1 through 2 (of 2 total)

Please to reply to this topic.


We're not around right now. But you can send us an email and we'll get back to you, asap.


About Us

Forcetalks is a Salesforce collaboration platform for coders & developers, geeks & nerds, consultants & business heads, admins & architects, managers & marketers and of course the business owners. A community where you can learn from, where you can contribute to. For you. For Salesforce. Read More...

Copyright 2019 Forcetalks. All Right Reserved.

Log in with your credentials


Forgot your details?