+ Start a Discussion
Sanjeev R 1Sanjeev R 1 

Import CSV using Apex and VisualForce

I need to populate Custom object using CSV(xls) import using Apex and visualforce, 
I m following this link
http://www.forcetree.com/2010/08/read-and-insert-records-from-csv-file.html

But requesting to please me the number of records(limitation), I can have via this functionalilty,can I upload bulk records using this.

thanks,
Sanjeev

EnreecoEnreeco
Hi Sanjeev,
if you want to overcome limits and use bulk, you must call the bulk APIs, thus calling from APEX your ORG's bulk apis (using the quick start guide on https://www.salesforce.com/us/developer/docs/api_asynch/ ).

--
May the Force.com be with you!
Sanjeev R 1Sanjeev R 1

I need to extract data from uploaded CSVand import that to Salesforce (applying some bussiness logic to filter data).. 
Please can I get some example for using it thr. bulk methods you stated above.

EnreecoEnreeco

Bulk APis process involves (more or less) this flow:

  1. Send CSV to Bulk API (using SOAP)
  2. Wait for the response
  3. Retrieve the response
This is an example using Java (https://developer.salesforce.com/forums/ForumsMain?id=906F000000093srIAA), you should translate it into APEX to make it work.
This is a great example of how to call the APIs from scratch (https://developer.salesforce.com/page/Loading_Large_Data_Sets_with_the_Force.com_Bulk_API).
Unfortunately this is not a simple task and there aren't many example out there to do this using APEX (because bulk APIs are intended to be used from external clients).

 
bruno.lubebruno.lube
Update. This will help:
http://www.sfdcpoint.com/salesforce/import-csv-file-using-apex-visualforce/