2011-02-24 70 views
2

我试图对某些用户已下载特定内容对象进行分析。在用户界面上,我可以看到谁(以及何时)被下载。有谁知道什么对象,我可以使用SOQL看到当用户X下载文档Y.Salesforce SOQL查询以检索下载内容的用户

感谢

+0

它们要么附件(与父对象)或文件(无父母),我建议从Web服务API文档开始,它是数据模型部分 - http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_erd_documents.htm - 不幸的是,它不会告诉您需要知道什么,但可能会提供一些指示。 – 2011-02-25 13:48:06

+0

您是否正在讨论关于CRM内容或标准附件和文件? – 2011-03-01 23:43:10

回答

2

下载内容存储在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