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
Paul McMurrughPaul McMurrugh 

Reference Contract on Custom Object Visualforce Page

Hi, I have table on a Custom Object Visualforce page and what to reference the Contract Number on it. I'm having trouble getting this to show on there as the Custom Object isn't directly related to Contracts (but Contracts does appear as a Related List on there).

How do I get the Contract Number to appear on my Visualforce page?

Thanks.
Best Answer chosen by Paul McMurrugh
ManojjenaManojjena
Hey Paul,

Here what my understanding is proposal is the parent of contract so you can't use Contract__r .This __r is to refer to the parent field not th echild field .so if you have any class related to this page you can get through that and create a get/set property for that and use in VF .

All Answers

sandeep sankhlasandeep sankhla
Hi Paul,

Can you explain more what exactly you need..also if it is coming in related list then there must be a relationship which we can use to show in VF page..

 
ManojjenaManojjena
Hey Paul,

Please explain your requirment properly ,It is not clear enough to giv esolution .
Paul McMurrughPaul McMurrugh
I have a Custom Object called 'Proposal'. When a 'Proposal' completes a Contract is automatically created through Apex Triggers/Classes, so this is why Contracts appears in a related list on the 'Proposal'.

I have a table on a Visualforce page and I want to 'pull through' the Contract Number.

I have tried the following below, but I think the bit in bold is where I'm going wrong.
<table style="float: left" border="1" cellpadding="6" cellspacing="0" width="75%">
<tr>
<td width="50%"><b>Contract Number:</b>
</td>
<td width="50%">
<apex:outputText value="{!Proposal__c.Contract__r.ContractNumber}"/> &nbsp; 
</td>
</tr>
</table>
I get the following error;
Error: Invalid field Contract__r for SObject Proposal__c
I hope that is a bit clearer.
ManojjenaManojjena
Hey Paul,

Here what my understanding is proposal is the parent of contract so you can't use Contract__r .This __r is to refer to the parent field not th echild field .so if you have any class related to this page you can get through that and create a get/set property for that and use in VF .
This was selected as the best answer