4

My Client wants to upload Image files from Account and generate a link for this image file and save it in a custom field on Account. This link should be Public Accessible (access from outside without the salesforce login prompt).

I tried using the ContentDownloadUrl field on ContentDistribution object.

For this I wrote a simple trigger on ContentDocumentLink object.

My problem is that a record inserted to ContentDistribution object and ContentDownloadUrl field populated when only user manually share the file from "Share via Link" menu option.

Is there any way to automate this process? Just populate this Public Accessible link using a APEX trigger when user upload an image?

Note : client wants to put this link inside a <img src=""> tag of his another site.

  • 2
    This sounds like a good use case for a custom object to hold both the image and the utl link for the image where you can control the sharing on them much more easily than you can using Content and ContentDocumentLink. If is "another site" isn't a Salesforce Sites, the Account Image won't be accessible to the site vistor through any link you set up. – crmprogdev Jul 14 '18 at 12:56
  • Actually this image link will be accessed from Marketing cloud in an email template. So, need to access this image URL without the login prompt. – Dinesh Wickramasinghe Jul 15 '18 at 15:16
2

If you're using these as content also sent from Marketing Cloud, you should be using Marketing Cloud Content Builder features including File Transfer Locations for Marketing Cloud Enhanced FTP Sites. Marketing Cloud tools will create the hyperlinks for you when you Create Content Blocks.

The source images, will not be accessible to external users if stored in the Account Object. Since you will be using the images for multiple purposes, I recommend you create a custom object to store them in. Create a custom hyperlink field in the Account Object if you want to display them on their related records. Let Journey Builder and other Marketing Tools do their parts separately when it comes to creating links for use with those particular tools. I don't think you're going to be able to create a single link from the Account to image that will serve for all your purposes.

  • Hi @crmprogdev Thanks for the idea. I wrote two triggers, one on ContentVersion and other one on ContentDistribution and seems working. I will test more and update you. – Dinesh Wickramasinghe Jul 18 '18 at 8:46
  • You're welcome @DineshWickramasinghe. If this post leads you to solving your issue, please help the rest of the community by marking it as having answered your question. If you don't, it leaves the impression to anyone who searches the topic later that your question wasn't answered to your satisfaction. If you have sufficient reputation, you can also upvote posts and answers. – crmprogdev Jul 18 '18 at 15:48

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.