Saturday 10 March 2012

Visualforce page for displaying the related contacts based on selected account using map

Controller:
=========

public class lonchangeaccount{
        public id aid{get;set;}
        public boolean render{get;set;}
     
        List<selectoption> options=new List<selectoption>();
        public  List<Contact> lstcont{get;set;}
        public lonchangeaccount(){
                    lstcont=new List<contact>();
           
            }
     
        Map<id,List<contact>> maplstcont=new Map<id,List<contact>>();
        public List<SelectOption>  getValues(){
                options.add(new selectOption('--None--','--None--'));
                for(Account acc:[select id,name,(select id,name,email from contacts)from account]){
                    options.add(new selectOption(acc.id,acc.name));
                    maplstcont.put(acc.id,acc.contacts);
               
                }
                return options;
        }
        public void  Contactlst(){
                        lstcont.clear();
                       if(aid!=null){
                            render=true;
                            lstcont.addAll(maplstcont.get(aid));
                        }
         }
}
Page:
==========================

<apex:page controller="lonchangeaccount">
<apex:form >
    <apex:pageBlock >
         <apex:actionFunction action="{!Contactlst}" name="change"/>
         <apex:selectList value="{!aid}" multiselect="false" size="1" onchange="change();">
                <apex:selectOptions value="{!values}"/>
            </apex:selectList>
          <apex:outputPanel rendered="{!render}" id="balu">
              <apex:pageBlockTable value="{!lstcont}" var="c">
                      <apex:column value="{!c.name}"/>
              </apex:pageBlockTable>
         
         </apex:outputPanel>
   
    </apex:pageBlock>
    </apex:form>

</apex:page>

Output:
============


How to include a screen flow in a Lightning Web Component

 Hi, Assume  you have a flow called "Quick Contact Creation" and API Name for the same is "Quick_Contact_Creation". To i...