You need to sign in to do that
Don't have an account?
swapnil kale
If we consider that I we get about 7000 oppty string csvContent size gets exceeded and I get Apex heap size too large error.
How should I handle this?
Apex heap size too large while creating an .CSV file
Hi,
I am attaching a csv file and following is the code
List<Opportunity> listCurrentShowOpportunities = [select Name,OwnerId,AccountId,StageName,Probability,TotalOpportunityQuantity,Amount,Description,CloseDate from opportunity] ; String csvContent = 'Name,Owner Name,Owner Id,Account Name,Account Id,Stage Name,Probability,Total Opportunity Quantity,Amount,Description,Close Date'+'\n'; for (Opportunity opp : listCurrentShowOpportunities){ csvContent = csvContent + opp.Name + ',' + opp.Owner.FirstName + opp.Owner.LastName + ',' + opp.OwnerId + ',' + opp.Account.Name + ',' + opp.AccountId + ',' + opp.Show__r.Name + ',' + opp.Show__c + ',' + opp.StageName + ',' + opp.Probability + ',' + opp.Item__c + ',' + opp.Item_Type__c + ',' + opp.Product_Family__c + ',' + opp.TotalOpportunityQuantity + ',' + opp.Sales_Price__c + ',' + opp.Amount + ',' + opp.Description + ',' + opp.CloseDate + '\n'; } Attachment attachment = new Attachment(); attachment.Body = Blob.valueOf(csvContent); attachment.Name = 'csvFile.csv'; attachment.ParentId = parentid; insert attachment;Where listCurrentShowOpportunities does not have any limit. I asume it to be size limit of list.
If we consider that I we get about 7000 oppty string csvContent size gets exceeded and I get Apex heap size too large error.
How should I handle this?
https://help.salesforce.com/apex/HTViewHelpDoc?id=collab_files_size_limits.htm