0

I have a URL which is a PNG file which is hosted on external cloud and I would like to create a new file with this image in my salesforce opportunity object as a file. Could anyone point me on how to do this ? Thanks in advance

ContentVersion contentVer = new ContentVersion(Title = 'Image',
                                      ContentUrl = 'https://xxxxxxx'
                                     );
insert contentVer;

ContentDocument contentDoc = [SELECT Id FROM ContentDocument WHERE Title = 'Image'];

ContentDocumentLink contentDocLink = new ContentDocumentLink();
contentDocLink.ContentDocumentId = contentDoc.Id;
contentDocLink.LinkedEntityId= '0061l00000LLtmgAAD';
contentDocLink.ShareType='V';
contentDocLink.Visibility='AllUsers';
insert contentDocLink;
2
  • so, what's not working?
    – cropredy
    Commented Nov 4, 2020 at 21:56
  • I get nothing, I mean just a blank file Commented Nov 4, 2020 at 22:06

0

You must log in to answer this question.

Browse other questions tagged .