+ Start a Discussion
Firoz AkhtarFiroz Akhtar 

Error:Could not resolve the entity from <apex:outputField> value binding,<apex:outputField> can only be used with SObjects, or objects that are Visualforce field component resolvable

Hello guys.

Need help on this, I am getting this error while saving my vf page code.any idea on this how to resolve this.below is the class and page code.Here I want to display  Name field of User object on VF page. there is lookup relationship between User and Employee object  and User is parent.
Please help me on this.Thanks in advance.

<apex:pageblockTable value="{!allemployees}" var="emp">
    <apex:column >
      <apex:facet name="header">
          <apex:outputText value="Full name"/>
        </apex:facet>
     <apex:outputField value="{!emp.User__r.Name}"/>
  </apex:column>
</apex:pageblockTable>

public List<Employee_Detail__c> getallemployees() 
       { 
         allemployees= Database.Query('select Image__c,User__r.name from Employee_Detail__c)
       return allemployees;
       }
Vinita_SFDCVinita_SFDC
Hi,

Try to query like this:

SELECT Image__c, (SELECT User__r.name FROM Employee_Detail__c.User__r) FROM Employee_Detail__c

Refer: http://www.salesforce.com/us/developer/docs/dbcom_soql_sosl/Content/sforce_api_calls_soql_relationships.htm
firoz1.3965969408507407E12firoz1.3965969408507407E12
Hi Vinita,

Thanks for your reply, I have tried this and code is get saved but getting another error while loading the page , below is the error message.

"caused by: System.QueryException: Didn't understand relationship 'User__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names."
This is is the exact qurey which I have modified after your suggestion 
allemployees= Database.Query('select id,Image__c,(select User__r.name from Employee_Detail__c.user__r) from Employee_Detail__c' );
Any Idea,please let me know

Thanks 




Vinita_SFDCVinita_SFDC
Try this:

SELECT Image__c, (SELECT Name FROM User__r) FROM Employee_Detail__c

If this doesn't work, please try to understand how the objects are related and which kind of query should be written. Refer following document which covers various scenarios.

https://developer.salesforce.com/page/A_Deeper_look_at_SOQL_and_Relationship_Queries_on_Force.com