[英]How to retrieve parent object field values in SOQL to display in VF Page
I am new to SFDC, struggling to retreive parent objects fields through SOQL query on child object. 我是SFDC的新手,正在努力通过对子对象的SOQL查询来检索父对象字段。 I have two objects namely Opportunity and Scope where Scope has a lookup to Opportunity.
我有两个对象,即商机和范围,其中范围是对商机的查找。
Here is the query i have written in Controller. 这是我在Controller中编写的查询。
ScopeController.cls: ScopeController.cls:
List<Scope> scopeList=[Select id,Name,ScopeValue__c,Opportunity__c,Opportunity__r.opAmount__c from Scope__c];
System.debug('scopeList : '+scopeList);
Accessing the values of scopeList in below VF Page. 在VF页面下方访问scopeList的值。
ScopePage: ScopePage:
<apex:repeat value="{!scopeList}" var="s">
<tr>
<td>{!s.Name}</td>
<td>{!s.ScopeValue__c}</td>
<td>{!s.Opportunity__c}</td>
<td>{!s.Opportunity__r.opAmount__c}</td>
</tr>
</apex:repeat>
But in the above VF Page not able to show the value of s.Opportunity__r.opAmount__c, it is empty. 但是在上面的VF页面中无法显示s.Opportunity__r.opAmount__c的值,它为空。 I debugged in Controller, the SOQL query itself not retrieving the value of "Opportunity__r.opAmount__c" hence shown empty in VF Page.
我在Controller中进行了调试,因此SOQL查询本身未获取“ Opportunity__r.opAmount__c”的值,因此在VF页面中显示为空。
One reason could be that your profile does not have access to this field (Opportunity__r.opAmount__c). 原因之一可能是您的个人资料无法访问此字段(Opportunity__r.opAmount__c)。
Query looks fine to me. 查询对我来说很好。 Do you see this value on the standard layout.
您在标准版式上看到此值了吗? Does your profile have access to this field?
您的个人资料可以访问此字段吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.