简体   繁体   English

如何根据案例 ID 从 ContentVersion 获取二进制数据

[英]How to get binarydata from ContentVersion based on Case ID

I need help to make a soql to get the images from ContentVersion based on caseId我需要帮助来制作一个 soql 以根据 caseId 从 ContentVersion 获取图像

We have 3 objects: ContentDocument ContentVersion ContentDocumentlink我们有 3 个对象: ContentDocument ContentVersion ContentDocumentlink

ContentDocument is parent of ContentVersion and ContentDocumentLink ContentDocument 是 ContentVersion 和 ContentDocumentLink 的父级

ContentVersion has versiondata(that is binary data) ContentDocumentLink having case id(Fieldname is LinkedEntityId) ContentVersion 有版本数据(即二进制数据) ContentDocumentLink 有 case id(Fieldname 是 LinkedEntityId)

I need to create a SOQL that provides version data of ContentVersion based on linkedentityID ( case- ID) when I use this query当我使用此查询时,我需要创建一个 SOQL,它根据 linkedentityID ( case-ID) 提供 ContentVersion 的版本数据

select versiondata from contentversion where contentdocumentid in(select contentdocumentid from contentdocumentlink where linkedentityid in(select id from case)) select versiondata from contentversion where contentdocumentid in(select contentdocumentid from contentdocumentlink where linkedentityid in(select id from case))

Than it is giving the error like Entity 'contentdocumentlink' is not supported for semi join inner selects比它给出的错误像 Entity 'contentdocumentlink' is not supported for semi join inner selects

It is giving error like semi join is not supported.它给出了不支持半连接的错误。

This works with any id (any object that you marked as allow attachments)这适用于任何 id(您标记为允许附件的任何对象)

SELECT ContentDocument.LatestPublishedVersion.VersionData 
FROM ContentDocumentLink 
WHERE LinkedEntityId = '...'

Or top-down (useful if you need multiple records and their files)或自上而下(如果您需要多个记录及其文件,则很有用)

SELECT Id, CaseNumber, Subject, 
    (SELECT ContentDocument.LatestPublishedVersion.VersionData FROM ContentDocumentLinks)
FROM Case
WHERE Id = '...'

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM