+ Start a Discussion
Austin MayerhoferAustin Mayerhofer 

Storing/sharing files with users?

Hi all, I'm creating an inventory management system for a group of customers. They want to be able to keep a database of food items (I've created a custom object food__c) and invoices (I've been using Salesforce files).

I created a VF/Apex page for invoice parsing. The database of food items works. The invoice pdf I store in Salesforce files using ContentVersion and then I use ContentDocumentLink to upload the pdf to the Group I'm in.

I'm wondering though, the sharing setting for food__c is that "All users can see this list view", is there a similar behavior that's possible for Salesforce files? So that all users can go to "files" and see the files that have been uploaded? Or will I still have to use ContentDocumentLink to store the files in the Group so that everyone can see them?

Also, is it possible to attach a custom 6 digit ID to an uploaded file? Maybe I can do this in Object Manager for ContentVersion?

Appreciate any help!
Abhishek BansalAbhishek Bansal
Hi Austin,

You can set the sharing of the files while creating the ContentDocumentLink using the ShareType field. There are three values you can pass to this field: 
V -> Viewer permission. The user can explicitly view but not edit the shared file.
C -> Collaborator permission. The user can explicitly view and edit the shared file.
I -> Inferred permission. The user’s permission is determined by the related record. For shares with a library, this is defined by the permissions the user has in that library. Inferred permission on shares with libraries and file owners is available in API versions 21.0 and later. Inferred permission on shares with standard objects is available in API versions 36.0 and later.
cdl.shareType = 'V' OR cdl.shareType = 'C' OR cdl.shareType = 'I'

You can also create custom fields on the ContentVersion object:

If you're using Lightning Experience, go to the Object Manager, select Content Version, then scroll to the fields area.
If you're using Salesforce Classic, enter Salesforce Files in the Quick Find box, then select Fields. 

Let me know if you need any further help or information on this.

Thanks,
Abhishek Bansal.