[SalesForce] How to export more than 50K records matching a query as a CSV

I'm building a CSV exporter for use within a Customer Portal that allows them to export in bulk some of their data (basically usage logs, which there are a ton of). For some super users there are more than 50K records available to them. Is there anyway to go about exporting 50K+ records as a CSV for this use case?

My understanding is that if you've got a query returning more than 50K rows your SOL if you want to build that into a CSV in a native context. I've already got a better solution (requiring a date filter to export) for longterm, but would be curious if the community has tackled this requirement before.

Restrictions

  • Can't use reports in customer portal
  • Can't use data loader as customer portal user

Best Answer

The 50k records returned by SOQL is a hard limit. I haven't heard of this particular limit being "black tab increased", but if the customer does not need much more than that it may be worth a try to contact their sales rep and ask.

Failing that, if the export is native Apex, you'll have to break it up into 50k row chunks.

It's possible that with HTML5/JS or Flash, and a clever paginated Apex exporter, you could simulate a larger-than-50k data load even though you're still only chunking out 50k records at a time. Also could look into a browser-based vanilla API integration which would also be able to get at more than 50k records at a time, although as you point out, customer portal users can't use the API.

If the exports aren't ad hoc, you could also do something like generating the export using an API integration running on a timed batch, but upload the large extract into Salesforce as a Document or Attachment. Then give your users the link to that uploaded document.

Related Topic