【问题标题】:How to retrieve parent object field values in SOQL to display in VF Page如何在 SOQL 中检索父对象字段值以显示在 VF 页面中
【发布时间】: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


    【解决方案1】:

    一个原因可能是您的个人资料无权访问此字段 (Opportunity__r.opAmount__c)。

    查询对我来说看起来不错。您是否在标准布局上看到此值。您的个人资料是否有权访问此字段?

    1. 从字段对象的管理设置中,转到字段区域。
    2. 选择要修改的字段。
    3. 单击查看字段可访问性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-18
      • 1970-01-01
      • 2021-11-15
      • 1970-01-01
      • 2022-07-27
      相关资源
      最近更新 更多