0

I have the following use case:

A web shop (Java) retrieving products from SF using the SOAP API. Attached "Files" are retrieved and displayed by selecting them through ContentDocumentLinks related to the Product2 object.

SELECT Id, Name, ProductCode, Description, IsActive, 
(SELECT ContentDocument.LatestPublishedVersionId FROM Product2.ContentDocumentLinks), 
(SELECT UnitPrice FROM Product2.PriceBookEntries LIMIT 1) 
FROM Product2 WHERE IsActive = true

This works, but not all files should be accessible in the web shop. I want to differentiate 3 types of files: Internal, Members only and Public. Our users are not "Salesforce" users (we retrieve data using one API user), so don't think sharing rules or groups can be used...

Best would be if I could change my subquery to: (SELECT ContentDocument.LatestPublishedVersionId FROM Product2.ContentDocumentLinks WHERE Type__c = 'Public') but I can't add fields to the ContentDocumentLink...

Any suggestions?

  • did you try leveraging the ContentDocument object? these can be placed in libraries (internal, Members Only, Public) and you can filter on Product2.ContentDocumentLinks where ContentDocument.Parent.Name = 'Public' – cropredy Mar 3 '18 at 0:22
1

I'd opt for using sharing rules if possible. If that is not an option, because the API user you are using needs access to more links than you want to render, then...

You could create a custom field on the Content version and filter it by the latest version.

(SELECT ContentDocument.LatestPublishedVersionId FROM Product2.ContentDocumentLinks WHERE ContentDocument.LatestPublishedVersion.Type__c = 'Public')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.