function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SarisfdcSarisfdc 

Save csv file in Document object through Visualforce page

Hi,

I want to create a visualforce page from where I select a csv file and upload into salesforce Document object.
Then from document object I need to read the uploaded file and insert into a custom object.
Please provide suggestions.

Thanks!
Siddharth ManiSiddharth Mani
Refer the below link for an example on how to attach a file using custom controller and VF Page:
http://blog.jeffdouglas.com/2010/04/28/uploading-an-attachment-using-visualforce-and-a-custom-controller/

If you have Notes and Attachments as a related list on the Custom Object, you can use the Id of the Custom Object's record as a Parent Id for the Attachment and it should show up automatically when you view the particular record. Even if you dont have a tab for the Custom Object, you can still use the Custom Object's Id as the ParentId of the attachment (Code is available in the link I gave above).

Let me know if it helps.
SarisfdcSarisfdc
Thanks Siddharth, this is helpful.
My next requirnment is to read the csv file saved in the attachments and insert records in a custom object.
please suggest!

Thanks!
sahitya adminsahitya admin
Hi need help,,can i create csv file in static resource using apex coding.In my project,i have written some batch class to insert data into Account Replica object.And i used database.insert.it will skip the failed records.but now i want to make the customers to see the failed records.how can i achieve this...?!urgent requirement,
Database.insert();