+ Start a Discussion

Save csv file in Document object through Visualforce page


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.

Siddharth ManiSiddharth Mani
Refer the below link for an example on how to attach a file using custom controller and VF Page:

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.
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!

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,