I'm trying to implement a feature in out customer portal that allows the users to upload a document (which is then stored as an attachment on a custom object) and retrieve it again. I've managed to get the upload and attachment working, but I can't figure out any way to let them download their own files again.

I've tried adding a link in the visualforce page using <a href="{!URLFOR($Action.Attachment.Download, '00P11000002edjREAQ')}">link</a> where the Id is the attachment Id, but this redirects to a standard 'insufficient privileges' page.

I've also tried using Content Delivery as suggested here, but it seems that this feature is not available to portal users. I can create a ContentVersion and ContentDistribution object and get the public url through anonymous Apex, but when I try the same code in the portal, even though the controller is set to without sharing, it seems to insert a ContentVersion object, but fails on the ContentDistribution with the error

insert failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []

So now I'm all out of ideas, surely there must be some way for portal users to access their own attachments?


The answer below was correct, the problem was that the custom object was in a Master-Detail relationship with a different one that had sharing set to private. This made the attachments private as well. This would have been easily solved by changing the Master object's sharing model but this was not possible due to business requirements.

Should anyone encounter a similar issue, we got around this limitation by using Chatter Files as storage instead, as they are directly visible to the user that uploaded them, and by turning on Feed Tracking for the custom object, could be linked directly to it as well.

  • kudos for the URLFOR function thanks, solved my issue :)
    – sskular
    Commented May 12, 2016 at 13:24

1 Answer 1


I tried your link in my org and it works in a community. Sounds like a sharing setting problem. You can change those under setup --> security controls --> sharing settings.

Also make sure to check your community profile under setup --> sites --> (click site label of community) --> public access settings.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .