Skip to main content

Hi, I can query on ContentDistribution the url of a file that I manually shared with external.

Is it possible to generate that url from Apex?

Thanks

6 answers
  1. Aug 14, 2018, 5:09 PM
    This way it worked, I can assign the ContentVersionId rather than ContentDocumentId.

     

    ContentDocumentLink cdl = [select contentdocument.id, contentdocument.title, contentdocument.filetype from contentdocumentlink where linkedentityid = '<Opportunity Id>'];

    ContentVersion cv = [select id from contentversion where contentdocumentid = :cdl.contentdocument.id];

    ContentDistribution cd = new ContentDistribution();

    cd.Name = 'Test';

    cd.ContentVersionId = cv.id;

    cd.PreferencesAllowViewInBrowser= true;

    cd.PreferencesLinkLatestVersion=true;

    cd.PreferencesNotifyOnVisit=false;

    cd.PreferencesPasswordRequired=false;

    cd.PreferencesAllowOriginalDownload= true;

    insert cd;

     
0/9000