function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dke01dke01 

Attachment Sharing

How does attachments and sharing work?

 

I thought that it would be setup as a mater-detail to the parent and the attachment sharing would be based off of the parents sharing rules?

 

I have a parent Object

 

Foo_c

 

User A is the Owner.   And I have given User B Read Write permission to a row.  This row has an attachment.

 

User A can view, edit the attachment find as he is the owner.

 

However

User B can access the attachment directly by going to the URL  /servlet/servlet.FileDownload?file= <ATTACHMENTID>

this works.

 

But doing a SOQL select stament for all attachments where parentID = xxx     Does not work for user B.

 

How can I fix this so User B can have the same sharing rules as user A.

 

There doesn not seem to be an Attachment__share object.   But there is a Foo__share Object  but these setting do not seem to carry across for attachments.

Best Answer chosen by Admin (Salesforce Developers) 
dke01dke01

Ok, It seems that I was wrong.

 

 

The Attachment sharing is based of the Parent Objects sharing rules so long as the attachment.isPrivate = false.

 

All Answers

imuino2imuino2

So, the only way to reffer to Attachments is thru object A?

You will need to make a new object where you relate A user attachments  to B users.

Let's say relation__c

 

make some custom fields

userBId__c here you will store the b object id

attachmentid__c here you will have your attachment id

 

Then all you need is to make a query where you retrieve the attachments based on the b user, and that way both users A and B will have access to the attachment thru soql.

 

Ignacio.

dke01dke01

Thanks, so basically by the sounds of things making a custom object  'relation__c'  is implementing my own version of _share object.

 

I will give it a try and see if it works.

 

I do not know why everything in salesforce is so inconsistant.  Why do documents have isPublic,  attachments have isPrivate and attachments uses a seperate security model then other custom sObjects.  Would make sense if they we could set the sharing settings/rules on attachments like regular sObject.

 

dke01dke01

Ok, It seems that I was wrong.

 

 

The Attachment sharing is based of the Parent Objects sharing rules so long as the attachment.isPrivate = false.

 

This was selected as the best answer