On Account field value change, need address values to change also

I have a master detail relation with Account(master) and Address_vod__c (child). I am showing Account as apex input field. Now on change of Account field , address values also need to changed. Please find below what I have tried.

Apex Page

 <apex:inputField value="{!Form_Requests_abv__c.Account_abv__c}" required="true"  id="check" />  <apex:pageBlockSectionItem >         <apex:outputText value="Address"  />        <apex:outputPanel styleClass="requiredInput" layout="block" id="pwPanel" >       <apex:outputPanel styleClass="requiredBlock"/>        <apex:actionRegion >         <apex:selectList size="1" value="{!AddressID}" required="true" >           <apex:selectOptions value="{!address}" ></apex:selectOptions>           <apex:actionSupport event="onchange" rerender="check" action="{!address}" status="Status1"/>       </apex:selectList>          <apex:actionStatus id="Status1" >                         <apex:facet name="start" >                           <img src="/img/loading.gif" />                                             </apex:facet>                     </apex:actionStatus>                 </apex:actionRegion>             </apex:outputPanel>     </apex:pageBlockSectionItem> 

Apex code

public List<SelectOption> getAddress()  {  AddID= new Set<ID>();  act =System.currentPageReference().getParameters().get('ABC');      List<SelectOption> optionaddress = new List<SelectOption>();      optionaddress.add(new selectoption('none','---Select--'));      for(Account ac: [Select Id,Name From Account where ID=:Test.Account_abv__c])      {         for(Address_vod__c c: [Select Id,Name,Address_line_2_vod__c, City_vod__c , State_vod__c , Zip_vod__c From Address_vod__c where Account_vod__c=:ac.ID ])               {  if(c!=null){              AddID.add(c.ID);              }          Address=c.Name+','+c.Address_line_2_vod__c+','+c.City_vod__c+','+c.State_vod__c+','+c.Zip_vod__c;            optionaddress.add(new SelectOption(c.ID,Address));         }        }        return optionaddress;       } 

Replay

I hope I understand well what you want to do.

public List<SelectOption> getAddress()
 {  AddID= new Set<ID>();
 act =System.currentPageReference().getParameters().get('ABC');
     List<SelectOption> optionaddress = new List<SelectOption>();
     optionaddress.add(new selectoption('none','---Select--'));
     for(Account ac: [Select Id From Account where ID=:Form_Requests_abv__c.Account_abv__c])
     {

       for(Address_vod__c c: [Select Id,Name,Address_line_2_vod__c, City_vod__c , State_vod__c , Zip_vod__c From Address_vod__c where Account_vod__c=:ac])
        {  if(c!=null){
             AddID.add(c.ID);
             }

        Address=c.Name+','+c.Address_line_2_vod__c+','+c.City_vod__c+','+c.State_vod__c+','+c.Zip_vod__c;

         optionaddress.add(new SelectOption(c.ID,Address));
        }

     }

     return optionaddress;    

}

Category: apex Time: 2016-08-01 Views: 84

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.198 (s). 12 q(s)