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
jaw999jaw999 

VF table for Custom object and related objects

Please, it's probably a minor error I am missing, but can someone tell me what I am missing?

 

I want to reproduce the basic functionality of this table, copied directly from the VF Dev guide:

 

<apex:page standardController="Account">
   <apex:pageBlock title=" {!$User.FirstName}!">
      {!account.name} account report.
   </apex:pageBlock>
   <apex:pageBlock title="Contacts">
      <apex:pageBlockTable value="{!account.Contacts}" var="contact">
         <apex:column value="{!contact.Name}"/>
         <apex:column value="{!contact.MailingCity}"/>
         <apex:column value="{!contact.Phone}"/>
      </apex:pageBlockTable>
   </apex:pageBlock>
</apex:page>

 But when I use my objects in this code:

 

<apex:page standardController="Customobject__c">
   <apex:pageBlock title=" {!$User.FirstName}!">
       {!Customobject__c.name} CDI Report.
   </apex:pageBlock>
    <apex:pageBlock title="Transcripts">
   <apex:pageBlockTable value="{!Customobject__c.CustomRelatedObj__c}" var="CustomRelatedObj__c">
         <apex:column value="{!CustomRelatedObj__c.Status__c}"/>
         <apex:column value="{!CustomRelatedObj__c.Knight_Products__c}"/>
         <apex:column value="{!CustomRelatedObj__c.Author__c}"/>
      </apex:pageBlockTable>
  </apex:pageBlock> 
</apex:page>

 I get error:

Error: Invalid field Transcript__c for SObject Client_Development_Initiative__c

 

I don't understand. Why does one of these lines work and not the other?

<apex:pageBlockTable value="{!account.Contacts}" var="contact">

<apex:pageBlockTable value="{!Customobject__c.CustomRelatedObj__c}" var="CustomRelatedObj__c">

 

Best Answer chosen by Admin (Salesforce Developers) 
jaw999jaw999

I found the error in my relationship syntax using the schema browswer in the Eclipse tool.

All Answers

Rakesh Aggarwal.ax1406Rakesh Aggarwal.ax1406

Can you make sure the relationship name is correct ? Is it Customobject__c.CustomRelatedObj__c or Customobject__c.CustomRelatedObj__r. Also I would advise using variable name(var) as CustomRelatedObj rather than CustomRelatedObj__c

jaw999jaw999
<apex:pageBlockTable value="{!Client_Development_Initiative__c.Transcript__r}" var="transcript">

 gets me the same error,

 Invalid field Transcript__r for SObject Client_Development_Initiative__c

 That it is saying "SObject" in the error message makes me pause.

jaw999jaw999

If i take the standard out of the opening line:

 

<apex:page Controller="Customobject__c">

 I get the nonsensical error message

	Error: The name can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores.	

 

which is a bug b/c my page name is "CDIR"

Naidu PothiniNaidu Pothini
<apex:pageBlockTable value="{!Client_Development_Initiative__c.Transcripts__r}" var="transcript">

 Try this.

 

-Naidu

jaw999jaw999

I found the error in my relationship syntax using the schema browswer in the Eclipse tool.

This was selected as the best answer
TescalanteTescalante

I am having  the same issue with this. Can you elaborate on how you figured out the correct syntax?