+ Start a Discussion
raga80raga80 

How to open parent records from custom button on child

Hi all, i have a custom object that is a related list of opportunity Object. Inside my custom object i have a custom buton that open a visualforce page with renderas=PDF.
<apex:page standardController="MiCustomObject__c">
How can i access Opportunity field from this page?
Can i access parent object from child?
Regards
Best Answer chosen by raga80
Vatsal KothariVatsal Kothari
What is API name of the field, which have master detail relation in Rata Object?

All Answers

Gooch ForeverGooch Forever
Please show your Code to get more help.
raga80raga80
<apex:page standardController="Rata__c"  showHeader="false" renderAs="pdf" standardStylesheets="false" applyBodyTag="false">

<table border="0" width="340">
<tr><td><strong>Buyer:</strong></td></tr>
<tr><td>{!Rata__c.Payment_Account__R.Name}</td></tr>
<tr><td>{!Rata__c.Payment_Account__R.BillingStreet}</td></tr>
<tr><td>{!Rata__c.Payment_Account__R.BillingCity}</td></tr>
<tr><td>{!Rata__c.Payment_Account__R.BillingCountry}</td></tr>
<tr><td>{!Rata__c.Payment_Account__R.BillingPostalCode}</td></tr>
<tr><td>{!Rata__c.Opportunity.Name}</td></tr>
</table>



</apex:page>

there is a master detail relationship bettween Opportunity and Rata__C
raga80raga80
with the error Error: Invalid field Opportunity for SObject Rata__c
Vatsal KothariVatsal Kothari
Hi,

Replace you below line
<tr><td>{!Rata__c.Opportunity__r.Name}</td></tr>
with
<tr><td>{!Rata__c.Opportunity__r.Name}</td></tr>
If this solves your problem, kindly mark it as the best answer.

Thanks,
Vatsal
raga80raga80
Not solve.
Error: Invalid field Opportunity__r for SObject Rata__c
I think that the problem is view parent field from child object
Vatsal KothariVatsal Kothari
What is API name of the field, which have master detail relation in Rata Object?
This was selected as the best answer
raga80raga80
Ok. Thankyou
The api name is Opportunita__c then :

{!Rata__c.Opportunita__r.Name}