0

Good Morning!

So while playing in the Sales force's playground, I came across an exciting toy(it might not excite someone) called content library. I have tried to understand how it works? who can access it? How you can restrict the permissions? All such generic question came across my mind and I tried to find an answer for them. There is one such question that is still my mind and unfortunately I couldn't find an accurate answer of that. So the question is,

I have thousands of my files that I want to store in Sales force and relate them with let's say accounts. So what are the options that I have to automate this process? Another thing, once I import all those files in Sales force content library and then moving forward I want to schedule a workflow or something that will pick up the file from a source and put it in the Sales force content library. Is this possible at all with Sales force? If so then what are my possible options?

Thanks Shubham

0

if you have thousands of my files that you want to store in Salesforce and relate them with let's say accounts. So the options that You have to automate this process are:-

First, make sure the file is inserted into Salesforce properly:-

Note:- verify that Upload Bulk API Batch as Zip File on the Settings | Settings page is enabled of data loader.

  • Create a CSV file. You need the following columns:

    • Title - file name.

    • Description - (optional) file or link description.

    • VersionData - complete file path including file's name and extension on your local drive (for uploading files only). Ex. C:\Users\jdoe\Desktop\PictureFile.jpg

    • PathOnClient - complete file path including file's name and extension on your local drive (for uploading files only).
    • Open Data Loader and click Insert.
    • Select the Show all Salesforce objects box.
    • Select ContentVersion.
    • Browse to your CSV file.
    • Click Create or Edit a Map then select Auto-Match fields to columns.
    • Click OK | Next | Finish.

Next, associate your content record to your records

  1. Create a CSV file. You need the following columns:

    • ContentDocumentId
    • Export the Content Document (ContentDocument) object.
    • Using the success file generated on the first step, you can do a Vlookup to get the corresponding ContentDocument ID for your files.
    • LinkedEntityId - id of the linked object. (i.e. Account ID.)
    • ShareType - Always use the value "V". The access of the Contact record to the file is always as a Viewer.
  2. Open Data Loader and click Insert.

  3. Select the how all Salesforce objects box.
  4. Select ContentDocumentLink.
  5. Browse to your CSV file.

Now, If you want to schedule a process that will pick up the file from a source and put it in the Salesforce content library, You can go for Batch Class to share the file with another library using the below code in execute method of your batch class.

ContentDocumentLink cdl = new ContentDocumentLink();
        cdl.ContentDocumentId = docId;
        cdl.LinkedEntityId = '058D00000004eQ5'; // workspaceId where user wants to publish the file.
        cdl.ShareType = 'I';
        cdl.Visibility = 'AllUsers'; 
        insert(cdl);

If you want this should happen as soon as you are inserting the file in Salesforce, You can go for Trigger. Refer this for Writing trigger:- Create Triggers to Customize File Sharing Behavior

Note:- Workspaceid is the id of the Library where you want to share the file

Reference:-

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.