用于检索下载内容的用户的 Salesforce SOQL 查询

发布于 2024-10-19 06:23:33 字数 108 浏览 0 评论 0原文

我正在尝试对哪些用户下载了特定内容对象进行一些分析。在用户界面上,我可以看到谁(以及何时)下载了它。有谁知道我可以使用 SOQL 查询什么对象来查看用户 X 下载文档 Y 的时间。

谢谢

I'm trying to run some analysis on which users have downloaded specific content objects. On the UI, I can see who(and when) it was downloaded. Does anyone know what object I can query using SOQL to see when User X downloaded Document Y.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

予囚 2024-10-26 06:23:33

内容下载存储在 ContentVersionHistory 对象中。如果您想查询用户 x 何时下载了文档 y,其中 x 是 User.Id,y 是 ContentVersion.Id,那么此代码将帮助您实现:

DateTime mostRecentDownloadDateTime;
Id downloadedById = '00550000001NLJsAAO';
Id contentVersionId = '068P000000005ck'; 
List<ContentVersionHistory> mostRecentDownload = 
[select createdDate, field from ContentVersionHistory 
 where createdById = :downloadedById 
 and contentVersionId = :contentVersionId 
 and field = 'contentVersionDownloaded'
 order by createdDate desc
 limit 1];
if(!mostRecentDownload.isEmpty())
 mostRecentDownloadDateTime = mostRecentDownload.get(0).createdDate;

注意内容版本和内容文档之间的差异。根据您的具体用例,您可能会更关心其中之一。

有关完整详细信息,请查看 Salesforce Webservices API 中的内容 ERD 和内容对象。
http://www.salesforce.com/us/developer/docs /api/Content/sforce_api_objects_contentversionhistory.htm
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_erd_content.htm

Content downloads are stored in the ContentVersionHistory object. If you wanted to query when user x downloaded document y, where x is User.Id, y is ContentVersion.Id, then this code will get you there:

DateTime mostRecentDownloadDateTime;
Id downloadedById = '00550000001NLJsAAO';
Id contentVersionId = '068P000000005ck'; 
List<ContentVersionHistory> mostRecentDownload = 
[select createdDate, field from ContentVersionHistory 
 where createdById = :downloadedById 
 and contentVersionId = :contentVersionId 
 and field = 'contentVersionDownloaded'
 order by createdDate desc
 limit 1];
if(!mostRecentDownload.isEmpty())
 mostRecentDownloadDateTime = mostRecentDownload.get(0).createdDate;

Be careful of the difference between content version and content document. Depending on your specific use case you may care about one over the other.

For full details check out the Content ERD and the Content Objects in the Salesforce Webservices API.
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_contentversionhistory.htm
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_erd_content.htm

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文