Need to build export to excel functionality on salesforce but the tricky and imoortant part is that data resides in some other cloud system not salesforce.

I have nearly 1 Million records in the third party system.

Please help me with design options and limitations around salesforce.

  • 1
    So you're using some sort of callouts to get the data from somewhere else, then you're trying to generate a CSV/"Excel-like" file in Apex Code? What exactly are you trying to do? – sfdcfox Jan 7 '16 at 1:36
  • Yes, that's correct. Need to provide export to excel button in salesforce. on click of that buttton- callout to thirdparty system should be made to fetch records. – Muddi Jan 7 '16 at 6:36

Assuming you're trying to get all 1,000,000 rows of data in at once, I think it's safe to say your task is virtually impossible. At minimum, you'll break the following governor limits: maximum CPU time, maximum heap, maximum callout size. Even running it as a batch process (which has relaxed governor limits), you'll still most likely exceed the heap limit, and you'd still need to iterate several times to avoid the callout limits.

However, you could write a batch process to handle iterating through all of the values in the external system, writing them to the database, then trying to run a report where you export all of the saved data to a CSV file, or using the Apex Data Loader to export the data.

Alternatively, you could try to perform the callouts directly from the client (the browser), assemble the file into a huge string, and convert it to a data-uri, which would allow users to download the file, assuming it was supported (all modern browsers supported by salesforce.com should allow such a download). Expect terrible performance. Either way, you'll have to page through the data in pieces rather than trying to get all the records all at once.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.