function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SF_DEV_CDESF_DEV_CDE 

Passing Account ID value to next section

Hi 
I have the code as below :

My Page:

<apex:page standardController="Account" extensions="accsearchconroller" sidebar="false" readOnly="true">
   <!--to reset/clear button - java script-->
   <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
         <script type="text/javascript">
            function resetForm(ele) {
                 $(ele).closest('form').find("input[type=text], textarea").val("");
                return false;
          }
   </script>
   
  <apex:pageMessages id="msg" />
   <apex:form id="formid">  
  
      <center><B>
      <apex:inputText value="{!searchstring}" label="Input" />
      <apex:commandButton value="Search Account" action="{!search}" />    
      <apex:commandButton value="Clear/Reset" onclick="return resetForm(this);" action="{!clear}" rerender="pbtable" immediate="true"/>  </B>
      </center>
      <h5 style="text-align:right;color:black;">
     <apex:outputText >  Please Enter full name/exact Account ID of the account for narrowing your search results </apex:outputText> </h5>
  <!--Page block starts-->
  
   <apex:pageBlock title="Search Result" id="pageblock" >  
    <apex:pageblockTable value="{!acc}" var="a" rendered="{!acc.size!=null}" id="pbtable">
     <apex:column headerValue="Account Name" >  
      <apex:outputlink value="/{!a.id}">{!a.Name}</apex:outputlink>  
     </apex:column>  
     <apex:column headerValue="Owner" value="{!a.owner.name}"/>  
     <apex:column headerValue="RecordType Name" value="{!a.recordtype.name}" />
     <apex:column headerValue="Bid Type" value="{!a.Bid_Type__c}"/>
      <apex:column headerValue="Faculty(s)" value="{!a.AAA_Faculty__c}"/>
    </apex:pageBlockTable>     
   </apex:pageBlock> 
   <apex:pageBlock >
    <apex:pageBlockSection title="Faculty">
       <apex:commandButton value="Display Faculty" action="{!faculties}" />  &nbsp;&nbsp; 
       <apex:pageblockTable value="{!faculty}" var="f" rendered="{!faculties.size!=null}" id="pbtable1"> 
        <apex:column headerValue="FacultyName" >  
         <apex:outputlink value="/{!f.id}">{!f.Name}</apex:outputlink>  
        </apex:column>  
           
       </apex:pageBlockTable> 
      </apex:pageBlockSection>
   </apex:pageBlock> 
  </apex:form>   
</apex:page>

My Controller:

 public with sharing class accsearchconroller {
   
    transient public list <account> acc {get;set;}  
    public string searchstring {get;set;}  
    public list <Faculty__c> faculties{get;set;}
    public String currentRecordId {get;set;}
   
   
     //constructor do nothing for now

    public accsearchconroller(ApexPages.StandardController controller) {
    

    }
   
    
    //Searching method with string
    public void search(){ 
    if (searchstring == null || searchstring.length()==0) {
    ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Please Enter the account Id to Search' );
      ApexPages.addmessage(msg);
           
      }else if(searchstring != null && searchstring.length()<=4) {
    ApexPages.Message msg = new Apexpages.Message(ApexPages.Severity.Warning,'Search text should have atleast 5 characters' );
      ApexPages.addmessage(msg);
             }
             
       else if(searchstring != null && searchstring.length()>4){
      string searchquery='select name,id,owner.name,recordtype.name,Bid_Type__c,SpareFoot_Account_Id__c,AAA_Faculty__c from account where (Bid_Type__c !=null AND SpareFoot_Account_Id__c like \'%'+searchstring+'%\')';  
      acc= Database.query(searchquery); } 
   }
     
   public void clear(){
   
   if(acc.size()!=0){
       acc = null;
   }
   }  
     //   for facility display
    public void faculties(){
    
     currentRecordId  = ApexPages.CurrentPage().getparameters().get('AccountId');
     faculties=[select id,name from Faculty__c where Account__c=:currentRecordId order by Name asc limit 30];
    }
 
}

And i wante to display the Faculties based on account id , but the above code is not working 

only account search is correct after that to display faculties - its not working , Please help on it.


Thanks
sweta
ankur manochaankur manocha
Hi Sweta, what error you get ?
SF_DEV_CDESF_DEV_CDE
I am unable to retrieve child records that is Faculty details on to VF page 
Shrikant BagalShrikant Bagal
Hi SF_DEV_CDE,

As per your code, you are display list of account.
then the faculty records which you want to show is on which Account Record.

let me correct if I am wrong.

thanks!
 
SF_DEV_CDESF_DEV_CDE
Account And Faculty are master detail relation ship

I have to add Radio button to it and get the id of account if they select that account and display all faculty related records on this page.

this is ths issue , i can only show them account search - i need this option.