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

filter selected contact from contact dropdownlist?
Hi All,
First I'm reading the all the salesforce Accounts in a selectoption dropdownlist.
based on the account selection i'm displaying the related contacts in other dropdownlist.
From the multiple contacts i'm selecting one contact how can i read that particular contact from
all contacts.
problem : how to filter selected contact from contact dropdownlist.
This is apex class:
public with sharing class Account_Contact_Picklist{
public String selectedAccId{get;set;}
public String selectedConId{get;set;}
public String firstname;
public String lastname;
public String email;
public String company;
public String mailingcity;
public String mailingstate;
public String mailingcountry;
public String mobileno;
public LightiningEd__Webinar_Attendees_Status__c login1;
public Account_Contact_Picklist(ApexPages.StandardController controller){
this.login1= (LightiningEd__Webinar_Attendees_Status__c)controller.getRecord();
}
public List<System.SelectOption> accOptions{get;set;}
public List<System.SelectOption> getAccountNames() {
List<System.SelectOption> accOptions= new List<System.SelectOption>();
accOptions.add( new System.SelectOption('','--Select--'));
for( Account acc : [select Id,name from Account] ){
accOptions.add( new System.SelectOption(String.valueOf(acc.Id),acc.name));
}
return accOptions;
}
public List<System.SelectOption> getContactNames(){
System.debug('Entered ContactNames account id...........'+selectedAccId );
List<System.SelectOption> conOptions= new List<System.SelectOption>();
List<System.SelectOption> options = new List<System.SelectOption>();
if(selectedConId != null){
System.debug('Entered ContactNames contact id1...........'+selectedConId );
for(contact con : [select Id,name,accountid,FirstName,LastName,email,MobilePhone,MailingCity,MailingState,MailingCountry
from contact where accountid=:selectedAccId ]){
conOptions.add(new System.SelectOption(String.valueOf(con.Id),con.name));
System.debug('conOptions:::'+conOptions);
if(conOptions.size() > 0){
system.debug('TestLog');
System.debug('SelectId::::'+selectedConId);
for(Contact con1 : [select Id,name,Account.Name,accountid,FirstName,LastName,email,
MobilePhone,MailingCity,MailingState,MailingCountry from contact where id=:selectedConId]){
firstname = con1.FirstName;
System.debug('Entered ContactNames contact id...........'+firstname);
lastname= con1.LastName;
System.debug('lastname:::'+lastname);
email = con1.Email;
System.debug('email:::'+email );
company = con1.Account.Name;
System.debug('company:::'+company );
mailingcity = con1.MailingCity;
System.debug('mailingcity:::'+mailingcity );
mailingstate = con1.MailingState;
System.debug('mailingstate:::'+mailingstate );
mailingcountry = con1.MailingCountry;
System.debug('mailingcountry:::'+mailingcountry );
mobileno = con1.MobilePhone;
System.debug('mobileno:::'+mobileno );
}
}
}
}
else{
conOptions.add( new System.SelectOption('--None--','--None--'));
}
return conOptions;
}
}
Thanks In Advance
First I'm reading the all the salesforce Accounts in a selectoption dropdownlist.
based on the account selection i'm displaying the related contacts in other dropdownlist.
From the multiple contacts i'm selecting one contact how can i read that particular contact from
all contacts.
problem : how to filter selected contact from contact dropdownlist.
This is apex class:
public with sharing class Account_Contact_Picklist{
public String selectedAccId{get;set;}
public String selectedConId{get;set;}
public String firstname;
public String lastname;
public String email;
public String company;
public String mailingcity;
public String mailingstate;
public String mailingcountry;
public String mobileno;
public LightiningEd__Webinar_Attendees_Status__c login1;
public Account_Contact_Picklist(ApexPages.StandardController controller){
this.login1= (LightiningEd__Webinar_Attendees_Status__c)controller.getRecord();
}
public List<System.SelectOption> accOptions{get;set;}
public List<System.SelectOption> getAccountNames() {
List<System.SelectOption> accOptions= new List<System.SelectOption>();
accOptions.add( new System.SelectOption('','--Select--'));
for( Account acc : [select Id,name from Account] ){
accOptions.add( new System.SelectOption(String.valueOf(acc.Id),acc.name));
}
return accOptions;
}
public List<System.SelectOption> getContactNames(){
System.debug('Entered ContactNames account id...........'+selectedAccId );
List<System.SelectOption> conOptions= new List<System.SelectOption>();
List<System.SelectOption> options = new List<System.SelectOption>();
if(selectedConId != null){
System.debug('Entered ContactNames contact id1...........'+selectedConId );
for(contact con : [select Id,name,accountid,FirstName,LastName,email,MobilePhone,MailingCity,MailingState,MailingCountry
from contact where accountid=:selectedAccId ]){
conOptions.add(new System.SelectOption(String.valueOf(con.Id),con.name));
System.debug('conOptions:::'+conOptions);
if(conOptions.size() > 0){
system.debug('TestLog');
System.debug('SelectId::::'+selectedConId);
for(Contact con1 : [select Id,name,Account.Name,accountid,FirstName,LastName,email,
MobilePhone,MailingCity,MailingState,MailingCountry from contact where id=:selectedConId]){
firstname = con1.FirstName;
System.debug('Entered ContactNames contact id...........'+firstname);
lastname= con1.LastName;
System.debug('lastname:::'+lastname);
email = con1.Email;
System.debug('email:::'+email );
company = con1.Account.Name;
System.debug('company:::'+company );
mailingcity = con1.MailingCity;
System.debug('mailingcity:::'+mailingcity );
mailingstate = con1.MailingState;
System.debug('mailingstate:::'+mailingstate );
mailingcountry = con1.MailingCountry;
System.debug('mailingcountry:::'+mailingcountry );
mobileno = con1.MobilePhone;
System.debug('mobileno:::'+mobileno );
}
}
}
}
else{
conOptions.add( new System.SelectOption('--None--','--None--'));
}
return conOptions;
}
}
Thanks In Advance
- When user select Account on VF page, Pass Account ID as Apex:Param now you have account id get list of contact and bind to picklist runtime
- Do not forget to render contact pick list.
Regards,
Niket