You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Salesforce中通过SOQL查询特定Account关联的Notes数据?

解决Salesforce中查询Account关联Notes返回空的问题

问题原因

你使用的Note是Salesforce旧版经典备注对象,而截图里的是Lightning Experience中的新版Notes,对应的数据对象为ContentNote,它通过ContentDocumentLink关联到Account,直接查询Note自然会返回空结果。

正确的SOQL查询方式

要查询指定Account关联的新版Notes,需关联ContentDocumentLink和ContentNote对象:

方式1:直接查询关联记录

SELECT 
    ContentNote.Title, 
    ContentNote.Body, 
    ContentNote.Id 
FROM ContentDocumentLink 
WHERE LinkedEntityId = '<你的Account ID>' 
AND ContentDocument.FileType = 'SNOTE'

方式2:从Account出发子查询关联Notes

SELECT 
    Id, Name,
    (SELECT 
        ContentDocument.Title, 
        ContentNote.Body 
     FROM ContentDocumentLinks 
     WHERE ContentDocument.FileType = 'SNOTE')
FROM Account 
WHERE Id = '<你的Account ID>'

补充说明

  • 旧版Note对象仅适用于Salesforce Classic,Lightning环境下创建的Notes都存储在ContentNote中,属于Files架构的一部分
  • ContentDocumentLink是连接业务记录(如Account)与ContentDocument(包含ContentNote)的中间关联对象
  • FileType = 'SNOTE'用于过滤出纯Notes类型的内容,避免查询到其他文件类数据

内容的提问来源于stack exchange,提问作者Shehzab Ahammad

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.02 05:30:46