我正在尝试编写 SOQL 查询来检索一些 Salesforce Content 记录,但在确定下一步时遇到了一些困难。如果该文档的任何版本的自定义字段具有值(不为空),我想排除该文档的所有版本。这是我正在尝试做的事情的简化版本:
Select Id, Title
From ContentVersion
Where ContentDocumentId Not In
(
Select ContentDocumentId,
From ContentVersion
Where Custom_Field__c != null
)
所以我知道你不能编写一个子查询来定位与其外部查询相同的对象,所以显然我上面指定的内容是行不通的。关于什么可行的任何建议?
谢谢。
最佳答案
你能尝试这样的事情吗:
Select C.Id from ContentDocument C where
ID not in ( Select ContentDocumentId
From ContentVersion
where Custom_Field__c != null)
关于具有自联接 + 关系的 Salesforce SOQL 查询(ContentDocument/ContentVersion),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8933165/