You need to sign in to do that
Don't have an account?

When ever we click he search we should display the perticular users, colud you please help on this
Hi All,
I have developed A vf page ,when ever we click the search button some licenced users should display the table. when ever i click it was displaying all the users in the table .
When ever we click he search we should display the perticular users, colud you please help on this.
Thanks in advace .
Regards,
Ramu.
I have developed A vf page ,when ever we click the search button some licenced users should display the table. when ever i click it was displaying all the users in the table .
When ever we click he search we should display the perticular users, colud you please help on this.
Thanks in advace .
Regards,
Ramu.
Can you please your VFP code here?
controller:
Thanks for the replay debarajan, these are the vf code we dont have access to copy paste out side and it wont allow to paste anywhere.
VFP--------------------------------------------------------------------
<apex:page Controller="SearchInVFController">
<apex:form>
<apex:inputText value="{!searchKey}" label="Input"/>
<apex:commandButton value="Search records" action="{!search}"/>
<apex:commandButton value="Clear records" action="{!clear}"/>
<apex:pageBlock title="Search Result">
<apex:pageBlockTable value="{!acc}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.id}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller----------------------------------------------------------------------------
public class SearchInVFController {
public list <Account> acc {get;set;}
public String searchKey {get;set;}
public SearchInVFController( ) {
}
public void search(){
string searchquery='select Name,id from account where name like \'%'+searchKey+'%\' Limit 10';
acc= Database.query(searchquery);
}
public void clear(){
acc.clear();
}
}
When we enter email id of an user and click on seach button i need to display a list of Active users in a apex controller.
Other wise it has to display all the users.
Probelm that i am facing:
I can display all the Active and inactive users in apex controller
based on your code for examle
public list <Account> acc {get;set;}
public void search(){
list<Account> lstac = new list<Account>();
If(picklistvalue==abcd){
string searchquery='select Name,id from account where name like \'%'+searchKey+'%\' Limit 10';
acc.add(lstac);
}else{
string searchquery='select Name,id from account where name like \'%'+searchKey+'%\' Limit 10';>>>>> exmp conditon I know
}
acc= Database.query(searchquery);
}
is this is the correct way?
please help me urgent.....
Thanks in advance
I can see in your previous code you used a 2 filter conditions
1. for Active users ( IsActive__c = true )
2. For email id ( OR email__c = \ ' '+SearchStrings+'\')
which is missing in your last code
As a result of which you are getting all the Active and inactive users in apex controller
So you need to change search() as
public void search(){
string searchquery='select Name,id from account where IsActive__c = true and email__c like \'%'+searchKey+'%\' Limit 10';
acc= Database.query(searchquery);
}
And that should work.
My actual code is
public class userviewcontroller{
public string searchstring {get;set;}
public List<userwrapper> userlist {get;set;}
public strig oppId {get;set;}
Map<string,user__x> usermap {get;set;}
public userviewcontroller(ApexPages.StanderdController controller)
{
searchstring ='';
userlist = new List<userwrapper>();
usermap= new Map<string,user__x>();
oppId = controller.getId();
}
public void serach(){
opportunity op =new oppertunity();
if(op.product__c =='Business product'){
string searchquery = 'select Id, ExternalId, Email__c,Pc_number__c,ISLicenced from User__x Where ISLicenced=true And (Email__c=\''+searchstring +'/' OR Pc_number__c=\''+searchstring +'/')';
}else{
string searchquery = 'select Id, ExternalId,Email__c,Pc_number__c,ISActive from User__x Where ISActive=true And (Email__c=\''+searchstring +'/' OR Pc_number__c=\''+searchstring +'/')';
List<user__x> users = Database.query(searchquery);
userlist = new List<userwrapper>();
for(user__x Us =users){
userlist.add(
userwrapper(Us)
);
usermap.put(Us.ExternalId,Us)
}
}
}
}
Here in if condition we are displaying Licenced users in else we are displaying all
But I am facing issue here
opportunity op =new oppertunity();
if(op.product__c =='Business product'){
string searchquery = 'select Id, ExternalId, Email__c,Pc_number__c,ISLicenced from User__x Where ISLicenced=true And (Email__c=\''+searchstring +'/' OR Pc_number__c=\''+searchstring +'/')';
}
Could you please correct my code
mine
where name like \'%'+searchKey+'%\'
where IsActive__c = true and email__c like \'%'+searchKey+'%\'
yours :
Where ISLicenced=true And (Email__c=\''+searchstring +'/' OR Pc_number__c=\''+searchstring +'/')';
so can you put
system.debug(searchquery);
after
string searchquery = 'select Id, ExternalId, Email__c,Pc_number__c,ISLicenced from User__x Where ISLicenced=true And (Email__c=\''+searchstring +'/' OR Pc_number__c=\''+searchstring +'/')';
to check what SOQL it make and execute the same from Dev Console Query Editor to ensure it was a Valid SOQL