Skip to main content
Is there any way to set 'Collaborators' as default for a file when it get uploaded? For each file upload, users need to go 'Sharing Setting' at the time of file upload. Is it possible to set 'Collarators' at a time as default for all files uploads so that the users don't have to go 'Sharing Settings' to set it for each and every file upload
1 answer
  1. Dec 28, 2018, 4:41 PM
    You need to add a trigger on the "ContentVersion" object so that a "ContentDocumentLink" gets created.  This represents a file sharing record.

     

    A rough, non-bulkified version that just handles a single user would be:

     

     

    trigger ContentVersionTrigger on ContentVersion (after insert) {

    insert new ContentDocumentLink(

      ContentDocumentId = trigger.new[0].ContentDocumentId,

      LinkedEntityId = '<a user id>',

      ShareType = 'C',

      Visibility = 'AllUsers'

      );

    }

    See the docs (

    https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_contentdocumentlink.htm) for more information on ContentDocumentLink

     

     
0/9000