You need to sign in to do that
Don't have an account?

How to reference a costum controller Field that is part of a lookup
Hello,
I have an orderposition that is referenced in a quotationposition. I now want to reference fields in the according orderposition.
In my VF page I tried to reference the following:
...
<apex:dataTable value="{!KV_Positionen}" var="KP" id="Table" styleClass="my_table">
<apex:facet name="header"></apex:facet>
<apex:column >
<apex:facet name="header">Anzahl</apex:facet>
<apex:Outputtext value="{!KP.Auftragspositionen__c.GenAnzVerp__c}"/>
</apex:column>
...
Auftragspositionen__c (orderposition) is a lookup in KV_Positionen (quotationposition).
My controller looks like:
...
KV_Positionen = [select name, KVA__c, Artikel__c, Auftragsposition__c, Verkaufspreis__c,
MWSt_1__c, MWSt_2__c, KK_Preis__c, gesetzl_zuzahlung__c, wirtschaftl_zuzahlung__c
from KVA_Position__c where Auftragsposition__c = :Apos.Id];
...
public KVA_Position__c[] getKV_Positionen()
{
system.debug ('KV_pos: ' + KV_Positionen);
return KV_Positionen;
}
I always get the error
Invalid field Auftragspositionen__c for SObject KVA_Position__c
If I try it with Auftragspositionen__r I get also an error.
Thanks in advance
Harry
I think this because you didnt query for field GenAnzVerp__c. You have to add this field in select query as like
KV_Positionen = [select name, KVA__c, Artikel__c, Auftragsposition__c,Auftragsposition__r.GenAnzVerp__c, Verkaufspreis__c,
MWSt_1__c, MWSt_2__c, KK_Preis__c, gesetzl_zuzahlung__c, wirtschaftl_zuzahlung__c
from KVA_Position__c where Auftragsposition__c = :Apos.Id];
and in VF
<apex:Outputtext value="{!KP.Auftragspositionen__r.GenAnzVerp__c}"/>
All Answers
I think this because you didnt query for field GenAnzVerp__c. You have to add this field in select query as like
KV_Positionen = [select name, KVA__c, Artikel__c, Auftragsposition__c,Auftragsposition__r.GenAnzVerp__c, Verkaufspreis__c,
MWSt_1__c, MWSt_2__c, KK_Preis__c, gesetzl_zuzahlung__c, wirtschaftl_zuzahlung__c
from KVA_Position__c where Auftragsposition__c = :Apos.Id];
and in VF
<apex:Outputtext value="{!KP.Auftragspositionen__r.GenAnzVerp__c}"/>
I agree with Dharmesh sample but simple mistake in VF code stuff
<apex:Outputtext value="{!KP.Auftragspositionen__r.GenAnzVerp__c}"/>
need to be changed
-Suresh
Hi Darmesh,
thanks, that works!
Harry
Hi Suresh,
thanks for the correction!
Harry