Display child records when selecting parent record from dropdown list?

444    Asked by ranjan_6399 in Salesforce , Asked on Jan 29, 2020
Answered by Ranjana Admin

 By using Action Support function we can achieve this scenario

public class ActionSupportController

{

    public list lstoption {get; set;}

    public list lstaccount {get; set;}

    Public List lstContacts {get; set;}

    Public string selectedAccount {get;set;}

        public ActionSupportController()

            {

                lstoption=new list();

                lstaccount= [select id,name from account order by name];

                lstoption.add(new selectoption('','--None--'));

                for(account acc: lstaccount)

                    {

                        lstoption.add(new selectoption(acc.id,acc.Name));

                    }

            }

    Public PageReference LoadContacts()

    {

        lstContacts = [select id, firstname, lastname,phone,LeadSource,Department,Status__c,Email from contact where accountid =: selectedAccount];

        return null;

    }


}





   

       

           

               

               

                 

       

   

   

       

           

           

             

             

             

             

       

   





Your Answer

Interviews

Parent Categories