You need to sign in to do that
Don't have an account?
STUCK ON BASIC! outputField can only be used with SObject fields
Hello,
i am trying to get fields from the parent custom object that i have created (Client), the child relationship name is "ActivitesClient__r" but i keep on getting
Error: Could not resolve the entity from <apex:outputField> value binding '{!c.ActivitesClient__r.Value_in_2009__c}'. outputField can only be used with SObject fields.
i have tried replacing apex:outputField with outputText but i goto the following error: Error: Unknown property 'VisualforceArrayList.Value_in_2009__c'
Value_in_2009__c is a custom field and set as a Text
here is the code
<apex:page standardController="Client__c" > <apex:variable value="{!Client__c}" var="c" /> <apex:form > <apex:pageBlock title="Activities"> <apex:pageblocksection > <apex:outputField value="{!c.Name}" /> <apex:outputField value="{!c.Chiffre_aff__c}" /> <apex:outputField value="{!c.ActivitesClient__r.Value_in_2009__c}" /> </apex:pageblocksection> </apex:pageBlock> </apex:form> </apex:page>
I dont have any idea why is this not working? I am referring a text using the childrelationship name..
You should be able to do use output fields for the referenced object, here's an example from one of my pages:
and this displays the account name as expected.
In your situation, is the related object a parent (i.e. does Client__c have a lookup field with an API name of ActivitesClient__r) or is Client__c the parent and ActivitesClient__r is a related list?
If its the latter, then you won't be able to refer to a field in that way, rather you'd need to iterate the related objects and output the detail for each one, e.g.
All Answers
outfield will refer to the object's field only not the referenced object.....
ok so do i need to cast this referenced object to a objectField ? or there is another fix..
why can't u use outputtext there...
You should be able to do use output fields for the referenced object, here's an example from one of my pages:
and this displays the account name as expected.
In your situation, is the related object a parent (i.e. does Client__c have a lookup field with an API name of ActivitesClient__r) or is Client__c the parent and ActivitesClient__r is a related list?
If its the latter, then you won't be able to refer to a field in that way, rather you'd need to iterate the related objects and output the detail for each one, e.g.
This code did not work for me returning "outputField can only be used with SObject fields":
In my case, Client__c is the parent.
Your solution worked, but meanwhile i used the apex:repeat to iterate over the ArrayList:
and then use it directly in a td:
I also tried your solution and it works like a charm, thanks a lot !