You need to sign in to do that
Don't have an account?

New To Salesforce CRM Content
Hi all;
I have several questions about Salesforce CRM Content.
1. Can I upload a file to Salesforce CRM Content by using Apex code? If so please tell how can I do that.
2. Can I display an image uploaded to Salesforce CRM Content on a visualforce page?
3. Is there a sObject which represents the Salesforce CRM Content, so that I can query data from that sObject?
If anybody knows an answer for at least one question please help me. If any question is not clear I'm ready to explain further. Thanks.
Hi Prageeth,
I think you can upload a file to content from Apex. Check out the this link for the SObject docs for storing the content.
The field "VersionData" will be helpful to store the binary of the file you want to store. From docs VersionData is base64 type and you might have to use <apex:inputFile> tag to select the file. The content will be tagged as type blob in apex controller class. Then you need to convert the blob to base64 using EncodingUtil class (System class).
Also you need keep in mind to fill the required information as given in docs as upload is done through apex and not by the system. Also please note that this will work on apex classes after API version 17.0.
For querying the content, VF page is not much suitable to show the data as view state size is limited for VF page. Instead you can use client side programs that will show the content. E.g. Java client s/w, Adobe flex (not very sure).
Hope this helps.
Cheers..
Here's a link to a step-by-step approach to programmatically uploading Content. Should give you what you need. Now, if you find an answer to embedding Content in VF, please let me know - I have an open post on this that SF seems to be ignoring...
Programmatically Upload Content
Hello Sarge and gtuerk;
Both of your answers were very useful. Actually I want to go a step further.
I want to know whether I could upload a "Visualforce PDF" file to CRM Content (Without using apex:inputFile tag).
For an example I can attach a file to an Opportunity as below.
Similarly can I upload an existing PDF file to the CRM Content ?
Any help would be highly appreciated.
I am ready to explain my requirement further if needed. Thanks.
Hello;
Finally I found something which looks like a solution. I could upload a VF page by using this method.
I am not very much sure whether this code is correct. If anybody can find errors in this code please point me to the correct direction.
Thank you.
I have a similar need. We have a VF Component which produces a PDF for us that is used by a VF page that creates a PDF preview in the browser. But I want to write a VF page that pushes the PDF either into Notes & Attachments or into a ContentWorkspace. Can you please help point me to a post or article that explains how to create the VF page to do that?
Thanks,
James