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
geetha b 8geetha b 8 

Here i am not getting Account Id

<apex:page standardController="Account" extensions="contrller">
  <apex:form >
    <apex:pageblock >
       <!-- Display Account related Contacts -->
       <apex:pageBlockTable value="{!relatedContacts}" var="val">
         <apex:column value="{!val.name}"/>
         <apex:column value="{!val.email}"/>
       </apex:pageBlockTable>
    </apex:pageblock>
  </apex:form>
</apex:page>


_________controller_______________

public with sharing class contrller {
Public id Current_Acc_Id;

    public contrller(ApexPages.StandardController controller) {
    Current_Acc_Id = controller.getRecord().id;
    system.debug('--------------------Current_Acc_Id------------------------'+Current_Acc_Id );
    }

    public List<Contact> getrelatedContacts(){
        List <contact> conList = New List<Contact>();
        system.debug('--------------------Current_Acc_Id------------------------'+Current_Acc_Id );
        for(Account acc:[select id,name,(select name,id,email from contacts) from account where id=:Current_Acc_Id])
        {
       
           for(contact con:acc.contacts)
               conList.add(con);
        }
        return conList;
    }
no records are displayed
 
PratikPratik (Salesforce Developers) 
Hi Geetha,

You can refer to below link:
https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_system_pagereference.htm

Sample code:

Public Class getrid {

    public string rid{get;set;}
    
    Public getrid ( Apexpages.standardcontroller controller) {
    rid=apexpages.currentpage().getparameters().get('id');
 }
}



Thanks,
Pratik


P.S. If this answers you question, please mark it as "Best Answer" so it will help other community members too.
RishavRishav
Hii  Geetha,
                 please pass  the account id  in  your URL  then it will return you the id of the current record in context.