2

我有以下三个自定义对象:

订购__c

Design__c(具有对 Order 的查找和对 Location 的查找,因此设计对象是联结对象)

位置__c

在订单页面布局上,我想添加一个包含 VF 页面的空白部分,以便显示订单的所有设计记录的位置记录。

一个订单可以有多个设计,一个设计可以有多个位置。我需要一种方法来对订单上的 VF 页面中的每个设计/位置进行分组和显示。

如何构建此查询并在 VF 页面上显示结果?

我正在尝试这样的查询: Select Location_ r.Name, Location _r.Mockup From Design_ c where Order _c = 'xxxxxxxxxxxxxx'

此外,除了相关列表中的 VF 页面部分之外,还有更好的方法来显示结果吗?

谢谢你的帮助!

问候。

4

1 回答 1

1

第一件事,第一件事。由于设计通过查找与其他 2 个对象相关,因此它不是连接对象。联结对象仅当它的 2 个父母与孩子有主从关系时。

我认为您要实现的是遍历父子父关系。您需要在后半部分使用子查询。从文档 - 你去: http: //www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_relationships.htm

Query **child-to-parent relationships**, which are often many-to-one. Specify these relationships directly in the SELECT, FROM, or WHERE clauses using the dot (.) operator.
For example:
SELECT Id, Name, Account.Name
FROM Contact 
WHERE Account.Industry = 'media'
This query returns the ID and name for only the contacts whose related account industry is media, and for each contact returned, the account name.




 Query **parent-to-child**, which are almost always one-to-many. Specify these relationships using a subquery (enclosed in parentheses), where the initial member of the FROM clause in the subquery is related to the initial member of the outer query FROM clause. Note that for subqueries, you should specify the plural name of the object as that is the name of the relationship for each object.
For example:
SELECT Name,
  (
    SELECT LastName
    FROM Contacts
  )
FROM Account
The query returns the name for all the accounts, and for each account, the last name of each contact.
于 2013-04-20T20:30:11.967 回答