Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in Salesforce by (11.9k points)

I have a custom object called Technology__c and join an object called AccountTechnologies which is a join object between Account and Technology__c .So AccountTechnologies has a master-detail relationship from both sides. I have added a count__c a roll-up summary field in the Technology__c to get the count But when I access it in the visual force page I get the following error

      System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Technology__c.count__c 

The following is the visualforce page code

 <apex:pageBlockTable title="Technologies" value="{!AllTechnologies}"
                <apex:column value="{!t.Name}" headerValue="Technologies" />
                <apex:column value="{!t.count__c}" headerValue="Count" width="20%">

1 Answer

0 votes
by (32.1k points)
edited by

If you're querying off of Technologies, the query would look like this:
[Select Id, Name, Count__c From Technology__c];

If you're querying off of a junction object, you would need to query the relationship using a subquery. You can check the Technology or AccountTechnologies object definition (App Setup > Create > Objects) and click the Master-Detail field to find the Child Relationship Name. Add an __r to that relationship name to find what object to subquery from.

Looking for a comprehensive Salesforce course? Enroll now!

Browse Categories