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
niladri_3121niladri_3121 

How to retrive the column from the picklist where i have given the fields of a particular object

VF PAGE:

<apex:page controller="search_global" tabstyle="account" sidebar="false">
<apex:form >
<apex:pageBlock title="Custom Search" mode="edit" id="block" >
<apex:pageBlockSection >
<apex:inputCheckbox label="Limit to accounts I own" />
<apex:pageBlockSectionItem >
<apex:outputLabel for="SearchText">Enter The Records Of Accounts
</apex:outputLabel>
<apex:panelGroup >
<apex:inputText id="searchText" value="{!searchText}"/>
<apex:commandButton value="Submit!" action="{!dosearch}" rerender="block" status="status"/>
</apex:panelGroup>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:actionStatus id="status" startText="requesting..."/>
<apex:pageBlockSection title="Results" id="results" columns="1">
<apex:pageBlockTable value="{!results}" var="l" rendered="{!NOT(ISNULL(results))}">
<apex:column value="{!l.name}"/>
<apex:column value="{!l.industry}"/>
<apex:column value="{!l.rating}"/>
<apex:column value="{!l.AccountPriority__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
<apex:form >
<apex:panelGrid columns="3" id="abcd">

<apex:selectList id="sel1" value="{!leftselected}" multiselect="true" style="width:100px" size="5">
<apex:selectOptions value="{!unselectedvalues}" />
</apex:selectList>
<apex:panelGroup >
<br/>
<apex:CommandButton value=" > " action="{!selectclick}"/> <br/>
<apex:CommandButton value=" < " action="{!unselectclick}"/>

</apex:panelGroup>
<apex:selectList id="sel2" value="{!rightselected}" multiselect="true" style="width:100px" size="5">
<apex:selectOptions value="{!SelectedValues}" />
</apex:selectList>
</apex:panelGrid>
</apex:form>
</apex:page>

 

CONTROLLER

 

public class search_global {

 

String searchtext;

String newsearchtext=searchtext+'%';
Set<String> originalvalues = new Set<String>{'name','Industry','Rating','AccountPriority__C'};
Public List<string> leftselected{get;set;}
Public List<string> rightselected{get;set;}
Set<string> leftvalues = new Set<string>();
Set<string> rightvalues = new Set<string>();

 

List<account> Results;

public String getsearchtext(){

return searchtext;

}

public Boolean check{

get{

if(check== null){

check = false;

}

return check;

}

set;

}

 

public void setsearchtext(String s)

{

searchtext=s;

}

public list<account> getResults()

{

return Results;

}

public pagereference dosearch()

{

if(check==false)

{

results=[select name,Industry,Rating,AccountPriority__C from account where account.name like :searchtext+'%' or industry=:searchtext or rating=:searchtext or AccountRegion__c=:searchtext or AccountPriority__c=:searchtext or AccountSummary__c like :searchtext+'%'];

}

else

{

results=[select name,Industry,Rating,AccountPriority__C from account where (account.name like :searchtext+'%' or industry=:searchtext or rating=:searchtext or AccountRegion__c=:searchtext or AccountPriority__c=:searchtext or AccountSummary__c like :searchtext+'%')and (ownerid=:UserInfo.getUserId())];

}

return null;

}
public search_global()
{
leftselected = new List<String>();
rightselected = new List<String>();
leftvalues.addAll(originalValues);
}
public PageReference selectclick()
{
rightselected.clear();
for(String s : leftselected)
{
leftvalues.remove(s);
rightvalues.add(s);
}
return null;
}
public PageReference unselectclick()
{
leftselected.clear();
for(String s : rightselected)
{
rightvalues.remove(s);
leftvalues.add(s);
}
return null;
}
public List<SelectOption> getunSelectedValues()
{
List<SelectOption> options = new List<SelectOption>();
List<string> tempList = new List<String>();
tempList.addAll(leftvalues);
tempList.sort();
for(string s : tempList)
options.add(new SelectOption(s,s));
return options;
}
public List<SelectOption> getSelectedValues()
{
List<SelectOption> options1 = new List<SelectOption>();
List<string> tempList = new List<String>();
tempList.addAll(rightvalues);
tempList.sort();
for(String s : tempList)
options1.add(new SelectOption(s,s));
return options1;
}

 

}

 

//Here i have added the code of  a search record  of Account object.i have added the picklist on the page thats having the account fields,but iam not able to filter the required fields from the Account records when iam selecting the particular field in the picklist,please provide me the solution.//