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 

Need to display child objects after getting my account result with Account Id

Not able to get Account id with the below code, can any one help me here


 public with sharing class accsearchconroller {
    
    transient public list <account> acc {get;set;}  
    public string searchstring {get;set;}  
    transient List<Account> AllAccountRecs = new List<Account>();
    public List<Facility__c> allfacilities = new list<Facility__c>();
  
  //constructor do nothing for now 
   public accsearchconroller() {

    }              
    //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 bid='Residual';
      string searchquery='select name,id,owner.name,recordtype.name from account where name like \'%'+searchstring+'%\''; 
      
      acc= Database.query(searchquery);     
     
      } 
   }     
   public void clear(){
     if(acc.size()!=0){
       acc = null;
   }
   }  
   //   for facility deisplay
      public void getallfac(){     
         String aId = ApexPages.currentPage().getParameters().get('acctId');     
     system.debug('***********************************************'+aId);    
         if(aId == null){            
           // return null;
         }
         else{
         allfaces = [select Id,Name From Facility__c where Account__c = :ApexPages.currentPage().getParameters().get('acctId')];}
         //return allfacilities;
     }   
   
}


Page: 



<apex:page Controller="accsearchconroller" sidebar="false" readOnly="true" tabStyle="Account">
   <!--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>
      <h5>  Account ID </h5>
      <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 Id of the account for narrowing your search results </apex:outputText> </h5>
  <!--Page block starts-->
  
   <apex:pageBlock title="Search Results" id="pageblock1" >  
    <apex:pageblockTable value="{!acc}" var="a" rendered="{!acc.size!=null}" id="pbtable1">
    <apex:inputHidden value="{!a.Id}" id="acctId">  
    <apex:param name="acctId" value="{!a.Id}"/>
    </apex:inputHidden>     
    <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:pageBlockTable>     
    </apex:pageBlock>  
  
 <apex:pageBlock title="Account - Faces" id="pageblock2">
  <apex:commandButton value="Diaplsy Faces" action="{!getallfac}"/>
    <apex:pageblockTable value="{!allfaces}" var="f" rendered="{!allfaces.size!=null}" id="pbtable2">   
    <apex:column headerValue="Facility Name" >  
      <apex:outputlink value="/{!f.id}">{!f.Name}</apex:outputlink>  
     </apex:column>          
    </apex:pageBlockTable>     
   </apex:pageBlock>
   
  </apex:form>
</apex:page>
Best Answer chosen by SF_DEV_CDE
SF_DEV_CDESF_DEV_CDE
This is solved thanks for reply

accid=[SELECT Id from Account WHERE condition].Id; 

All Answers

NagaNaga (Salesforce Developers) 
Hi SF_DEV,

DataTables' child row example is here: http://datatables.net/examples/api/row_details.html - if that's what you are looking for.

Best Regards
Naga Kiran

 
SF_DEV_CDESF_DEV_CDE
No , Actually I tried with data Tables also , remote action methods are not working for passing account id from search table to child records 
so trying with normal VF page - pageblocks.

Thanks for the help.
SF_DEV_CDESF_DEV_CDE
This is solved thanks for reply

accid=[SELECT Id from Account WHERE condition].Id; 
This was selected as the best answer