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

How to retrieve field value while i am getting field value id when i am trying to retrieve?
Hi All,
I am trying to retrieve a picklist value from page to control. In the control, I am getting the field value id and not the field value text. And i am retrieving using property fields like public String selecteduser{set;get;}.I need to use that retrieved value in a where clause of an query. Please tell me how can i get the picklist text value?
Tons of Thanks,
Nishanth.
Hi ,
can you post your code please?
Regards
I think you have to tweek the way you are generating your picklist to get the desired result. In the code for generation of picklist , in portion where you are assigning text and value of a picklist option programatically modify the value portion such that is look like this:-
say id+"-"+ text then as you get the value on the controller you can split it at the point where "-" is and extract the text.
In order to help you in a better way please do share the code which is bothering you so that we can give you a precise solution.
public class LocationControl{
public LocationMaster__c lm{get;set;}
List<LocationMaster__c> routelist = new List<LocationMaster__c>();
List<LocationMaster__c> doclist = new List<LocationMaster__c>();
List<LocationMaster__c> druggistlist = new List<LocationMaster__c>();
List<LocationMaster__c> stockistlist = new List<LocationMaster__c>();
List<selectOption> usersOptions=new List<selectOption>();
List<selectOption> usersOptions1=new List<selectOption>();
List<selectOption> usersOptions2=new List<selectOption>();
List<selectOption> usersOptions3=new List<selectOption>();
public String selecteduser{get;set;}
public String selecteduser1{get;set;}
public String selecteduser2{get;set;}
public String selecteduser3{get;set;}
String selecdteduser='Hyderabad-Afzalgunz-hyderabad';
public LocationControl(ApexPages.StandardController ctrl){
LocationMaster__c lm= new LocationMaster__c();
LocationMaster__c lm1= new LocationMaster__c();
lm1.route__c=lm.route__c;
routelist=[select route__c from LocationMaster__c];
usersOptions.add(new selectOption('Select','Select'));
for(LocationMaster__c userloop:routelist){
usersOptions.add( new selectOption(userloop.id,userloop.route__c));
}
}
public PageReference doprocess(){
System.debug('___________________________'+selecteduser);// this is where i am getting id instead of picklist value
usersoptions1.clear();
doclist=[select DoctorName__r.Name from LocationMaster__c where route__c=:selecteduser];
usersOptions1.add(new selectOption('Select','Select'));
for(LocationMaster__c userloop:doclist){
usersOptions1.add( new selectOption(userloop.id,userloop.DoctorName__r.Name));
}
druggistlist=[select DruggistName__r.Name from LocationMaster__c ];
usersoptions2.clear();
usersOptions2.add(new selectOption('Select','Select'));
for(LocationMaster__c userloop:druggistlist){
usersOptions2.add( new selectOption(userloop.id,userloop.DruggistName__r.Name));
}
stockistlist=[select StockistName__r.Name from LocationMaster__c ];
usersoptions3.clear();
usersOptions3.add(new selectOption('Select','Select'));
for(LocationMaster__c userloop:stockistlist){
usersOptions3.add( new selectOption(userloop.id,userloop.StockistName__r.Name));
}
return null;
}
public List<selectoption> getuserslist(){
return usersOptions;
}
public List<selectoption> getuserslist1(){
return usersOptions1;
}
public List<selectoption> getuserslist2(){
return usersOptions2;
}
public List<selectoption> getuserslist3(){
return usersOptions3;
}
}