I want to get the parent ID in my child custom controller. How can I do this, please ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The field that relates the parent object with the child object in the child contains the parent id. For Contact, it’s AccountId. For a custom object, it was set by the user creating the field. You can go to the child object and check.
Once you know the field name, you can access it directly. For Contact:
For an object with a MasterDetail (or lookup) field called Parent__c:
When retrieving data, using the suffix __c you get the Id of the target object in a relationship. Using the suffix __r you get the target object itself.