I create a very simple query to display the result at visualforce and render as pdf to store the pdf in an account. Unfortunately I ran always into Collection size 1.079 exceeds maximum size of 1.000 and I don't know how can I avoid this problem.
I found this solution, I edited my code but I still run into the error.
QUERY
public with sharing class FDB_Reporting {
public List<FDB_Aktivit_t__c> FDBList {get; private set;}
public Integer c1 {get; set;}
public Integer c2 {get; set;}
public Integer c3 {get; set;}
public Integer c4 {get; set;}
public Integer c5 {get; set;}
public Date FirstDayOfLastMonth {get; set;}
public Date LastDayOfLastMonth {get; set;}
public FDB_Reporting() {
FirstDayOfLastMonth = System.today().toStartOfMonth().addMonths(-1);
LastDayOfLastMonth = System.today().toStartOfMonth().addDays(-1);
FDBList = [SELECT Name, Account__c FROM FDB_Aktivit_t__c WHERE createdDate >= :FirstDayOfLastMonth AND createdDate <= :LastDayOfLastMonth];
c1= [SELECT COUNT() FROM FDB_Aktivit_t__c WHERE contactassign__c = '1' AND createdDate >= :FirstDayOfLastMonth AND createdDate <= :LastDayOfLastMonth];
c2= [SELECT COUNT() FROM FDB_Aktivit_t__c WHERE contactassign__c = '2' AND createdDate >= :FirstDayOfLastMonth AND createdDate <= :LastDayOfLastMonth];
c3= [SELECT COUNT() FROM FDB_Aktivit_t__c WHERE contactassign__c = '3' AND createdDate >= :FirstDayOfLastMonth AND createdDate <= :LastDayOfLastMonth];
c4= [SELECT COUNT() FROM FDB_Aktivit_t__c WHERE contactassign__c = '4' AND createdDate >= :FirstDayOfLastMonth AND createdDate <= :LastDayOfLastMonth];
c5= [SELECT COUNT() FROM FDB_Aktivit_t__c WHERE contactassign__c = '5' AND createdDate >= :FirstDayOfLastMonth AND createdDate <= :LastDayOfLastMonth];
}
}
CLASS to save the report
public without sharing class FDB_Export_Reports{
@InvocableMethod(Label = 'create FDB Reports' description='')
public static void FDB_Reports_PDF() {
PageReference page = Page.FDB_Reporting;
Blob contentBlob = !Test.isRunningTest() ? page.getContentAsPDF() : Blob.valueOf('Hardcoded sample text for Test class');
ContentVersion cv = new ContentVersion();
cv.VersionData = contentBlob;
cv.Title = System.today().year() + '_' + System.today().month() + '_FDB_Alle_Aktivitaeten';
cv.PathOnClient = System.today().year() + '_' + System.today().month() + '_FDB_Alle_Aktivitaeten.pdf';
insert cv;
cv = [SELECT Id, ContentDocumentId FROM ContentVersion WHERE Id = :cv.Id LIMIT 1];
ContentDocumentLink cdl = new ContentDocumentLink();
cdl.ContentDocumentId = cv.ContentDocumentId;
cdl.ShareType = 'I';
cdl.LinkedEntityId = '001b000000Zps12AAB';
insert cdl;
}
}
VISUAL FORCE
<apex:page controller="FDB_Reporting" renderAs="pdf" applyBodyTag="false" applyHtmlTag="false" showheader="false">
<html>
<head>
<style>
table { page-break-inside:auto;
border-collapse: collapse;
border: 1px solid;
}
tr { page-break-inside:avoid;
page-break-after:auto;
border: 1px solid;
}
th { background-color: #33C4FF;
border-color: black;
font-weight: bold;
border: 1px solid;
}
td { font-size: 9px;
border: 1px solid;
}
@page { size: A4 landscape;
}
</style>
</head>
<center>
<table style="font-family: sans-serif; font-size: 9px; border: 1px solid">
<tr>
<th>Name/Id</th>
<th>Account</th>
</tr>
<apex:repeat value="{!FDBList}" var="text">
<tr>
<td> {!text.Name}</td>
<td> {!text.Account__c}</td>
</tr>
</apex:repeat>
</table>
</center>
</html>
</apex:page>