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
Manpreet Singh 13Manpreet Singh 13 

sobject error

Hello All,

I have written below mentioned code and I am getting "Error: Invalid field Testing__r for SObject Case".

Please note, 'Testing' is a custom object and is related list of Case object

<apex:pageBlockSection id="Testing" columns="1" title="Testing" collapsible="true">
      <apex:pageBlockTable value="{!Case.Testing__r}" var="item">
      <apex:column value="{!item.Name__c}"/>
      
      </apex:pageBlockTable>
      
      </apex:pageBlockSection>
Best Answer chosen by Manpreet Singh 13
JayantJayant
Related object relationship names in SOQL should use the Plural version rather than Singular one (unless you have renamed the default Plural version).
Check the relationship name, I believe it might be Testings__r. 

All Answers

Alex Edwin 8Alex Edwin 8
I believe you need to use the relationship name. When you open the field you should see "Child Relationship Name".

!Case.<Child Relationship Name>
JayantJayant
Related object relationship names in SOQL should use the Plural version rather than Singular one (unless you have renamed the default Plural version).
Check the relationship name, I believe it might be Testings__r. 
This was selected as the best answer
Manpreet Singh 13Manpreet Singh 13
Thank you for your inputs. Actually, I fixed the issue by using plural form. Here is the final code


<apex:pageBlockSection id="Testing" columns="1" title="Testings" collapsible="true">

<apex:pageBlockTable value="{!Case.Testings__r}" var="item">

<apex:column value="{!item.Name}"/>

</apex:pageBlockTable>

</apex:pageBlockSection>
 
JayantJayant
If this is resolved, please do mark the question as Resolved and the most appropriate/helpful answer as the best answer :).
If none of the answers helped you significantly, please post the solution. You may also mark your solution as the best answer.