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
sowmyaa Yakkalasowmyaa Yakkala 

how to get ParentId in visualforce page?

In my Requirement, Parent Object  is  Contact and child Object is Hippa__c.  Here i need to get the Parent Id when ever i am creating a new records from Releated list of Contact. 
If any Know Plz help me....
Best Answer chosen by sowmyaa Yakkala
Khan AnasKhan Anas (Salesforce Developers) 
Hi Sowmya,

Greetings to you!

Please try below code:
public class ParentIdRelatedListC {

    public ParentidRelatedListC(ApexPages.StandardController controller) {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Parent record ID is '+((Hippa__c)controller.getRecord()).Contact__c));
    }
}

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas