Is it possible to get a sharing link (to non SFDC users) from ‘files’/’content’ via apex?

A bit of background: I have a client that I built a custom model library for, and in this page they can select a group of models and email them (say instructions to the next gig or notify them of upcoming events etc). The client wants to be able to share content in these emails, and at first we tried attaching the content (all of her doc’s are in in crm content) to the emails. The page would display a list of content that she could choose from to attach. This causes a few problems:

  • Since the fileType returned was not the type the email api was looking for it had to be converted so a custom setting is used…(my previous question about this) this has to be kept up to date manually and isn’t an ideal solution. If the right extension isn’t found the file defaults to a standard HTML doc and its up to the user to know what extension to save the file with.. and assuming that the end recipient isn’t a computer savvy person..this would not be a good user experience
  • There is a 10MB limit on emails and the attachments, so only 2 maybe 3 attachments could be included per email. Unfortunately she wanted to include much more than 2 or 3 attachments.
  • Since you cant search within the tag field on ContentVersion via SOQL, a trigger would be needed to replicate the tag field into a new one that can be searched, however, 1 of 3 ways tags are added to content doesn’t always fire a dml update so the trigger isn’t fired, and thus the field isn’t always up-to-date. So the content showing in the ‘send email’ page could get lengthy/unusable as content is added.

Whats needed is a way to send content to non-sfdc users that they can access/downloaded easily via a link (I think this is the best solution, but am open for suggestions). I would go the rout of making them all chatter users, but this is not an ideal solution since we want to avoid them having to log-in to anything/get setup etc. Also I would do a sites page, but again, this isn’t the best solution for security reasons. Since it seems that going the file attachment rout isn’t going work well with the use-cases, is there a way (via apex) to expose the content(or files) via link to non users?

When looking into this, it seemed that there are ways to do it via the UI but not the API, at least with CRM Content, and potentially chatter ‘files’. Questions:

  • In the UI for files I see that I can generate a link that anyone (even non-org users) can click and see, but not sure how to achieve that via the API

link that is shared

  • In CRM Content, there is the ability to group content and share it via a Content Pack, but I am not seeing a way to allow someone to create Content Packs via the API so it can be shared. Then once it is grouped, can it be shared to non-org users?
  • Based off this Question could I use the same approach in an email? Does it work with Content/Files?

Any help or direction for this would be awesome!


According to this post, the answer to your question about using content packs would be “no”.

On the IdeaExchange you’ll find a submission titled Allow Content Deliveries to be programmatically generated via Apex which has some related links on it you may also want to look at. Regardless, I believe this “idea” covers the gist of your question.

It seems to me that you might want to go and vote for this idea.

With a bit more effort, I believe I’ve found something in another post that you might be able to utilize the techniques from for getting a download link in it to accomplish your task. There are references to a blog post titled Salesforce: How to make a Document public? and some other useful discussion.

Based on the above referenced post, I’d say the answer to your final question is “yes”. Implementation will be a matter of how you design your trigger and email template(s).

For future reference, you might find FindSF Info to be a very helpful search engine.

Source : Link , Question Author : SalesForceGirl , Answer Author : Community

Leave a Comment