简体   繁体   English

如何在SOQL中检索父对象字段值以在VF页面中显示

[英]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? 您的个人资料可以访问此字段吗?

  1. From the management settings for the field's object, go to the fields area. 从字段对象的管理设置中,转到字段区域。
  2. Select the field you want to modify. 选择您要修改的字段。
  3. Click View Field Accessibility. 单击查看字段可访问性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在VF页面上显示多子查询,动态字段,动态对象SOQL查询结果 - Displaying multi-subquery, dynamic field, dynamic object SOQL query results on a VF page 如何通过在SFDC中通过父对象查询来在VF页面中显示子对象字段 - How to display child object fields in the VF page By querying through Parent object in SFDC 如何通过 SOQL Query 检索帐户对象 - How to retrieve account object through SOQL Query 如何在Salesforce中选择帐户时从帐户对象获取要加载到VF页面的字段 - How to get a field from account object to be loaded in VF page on selection of account in salesforce 如何在嵌入式VF页面中删除“案例所有者的hyperLink”字段? - How to remove the hyperLink for Case Owner field in an inline VF page? 如何打破vf页面中长文本区域字段的文本 - How to break the text of long text area field in vf page 如何在Vf页面中访问帐户对象的计费地址 - How to Acess Billing Adress of Account Object in Vf Page 如何使用 SOQL 从 Salesforce 中检索 2 object 字段 - How to retrieve 2 object fields from Salesforce using SOQL 如何在Visualforce页面上显示聚合SOQL查询的结果? - How do I display the results of an aggregate SOQL query on a Visualforce page? 如何打开VF页面作为弹出窗口并将参数传递给该VF页面? - How to open a VF page as popup and pass parameters to that VF page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM