【发布时间】:2017-03-14 20:10:34
【问题描述】:
我是 SFDC 的新手,正在努力通过对子对象的 SOQL 查询来检索父对象字段。 我有两个对象,即 Opportunity 和 Scope,其中 Scope 可以查找 Opportunity。
这是我在 Controller 中编写的查询。
ScopeController.cls:
List<Scope> scopeList=[Select id,Name,ScopeValue__c,Opportunity__c,Opportunity__r.opAmount__c from Scope__c];
System.debug('scopeList : '+scopeList);
在下面的 VF 页面中访问 scopeList 的值。
范围页面:
<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>
但是在上面的 VF 页面中无法显示 s.Opportunity__r.opAmount__c 的值,它是空的。我在 Controller 中调试,SOQL 查询本身没有检索“Opportunity__r.opAmount__c”的值,因此在 VF 页面中显示为空。
【问题讨论】:
标签: salesforce visualforce soql