You need to sign in to do that
Don't have an account?

View state error in my vf page
I am trying to insert 11 attachments through a single insert button in a custom object through VF page but getting view state error.
Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 146.86KB
<apex:page controller="GLADDDExtPortalCC" sidebar="false">
<apex:pagemessages />
<apex:sectionHeader title="Questionnaire" subtitle="Step 8 of 8"/>
<APEX:form >
<apex:pageBlock mode="edit">
<apex:pageBlockButtons >
<apex:commandButton value="Previous" action="{! step6}" style="background:#0070d2 !important; width:100px; color:white; padding: 5px;"/>
<apex:commandButton value="Save" action="{! save}" style="background:#0070d2 !important; width:100px; color:white; padding: 5px;"/>
<apex:commandButton value="Save and Next" action="{! step7}" style="background:#0070d2 !important; width:100px; color:white; padding: 5px;"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="References" columns="1">
<body>
<h1><u>GLADDD: Submission Document Checklist</u></h1>
<br></br>
<br></br>
<h1><u>Mandatory</u></h1>
<br></br>
<input type="checkbox"> GTS-BIS711
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachBis711.body}" filename="{! attachBis711.name}" id="file" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!-- <apex:commandButton value="Upload Required Documents" action="{! upload}"/> -->
<br></br>
<input type="checkbox"> CMP-Certification of Complaince
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachCertComp.body}" filename="{! attachCertComp.name}" id="file1" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!-- <apex:commandButton value="Upload Required Documents" action="{! upload}"/> -->
<br></br>
<input type="checkbox"> FN_DD Certification
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachDDcerti.body}" filename="{! attachDDcerti.name}" id="file2" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<br></br>
<h1><u>If Yes selected(A/D Questionnaire)</u></h1>
<br></br>
<input type="checkbox"> CMP-Anti-Corruption Policy
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachAntiCorr.body}" filename="{! attachAntiCorr.name}" id="file3" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<input type="checkbox"> CMP-Code of Conduct
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachCodeCond.body}" filename="{! attachCodeCond.name}" id="file4" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<br></br>
<h1><u>Non Mandatory</u></h1>
<br></br>
<input type="checkbox"> FN-Tax License
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachTaxLicen.body}" filename="{! attachTaxLicen.name}" id="file5" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<input type="checkbox"> FN-Bank Statement(Bank Reference Letter)
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachBankState.body}" filename="{! attachBankState.name}" id="file6" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<input type="checkbox"> FN-Medical Device Business Permit
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachMedicalDe.body}" filename="{! attachMedicalDe.name}" id="file7" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<input type="checkbox"> FN-Company Registration Certificate
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachCompReg.body}" filename="{! attachCompReg.name}" id="file8" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<input type="checkbox"> FN-Financial Statement
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachFinanStat.body}" filename="{! attachFinanStat.name}" id="file9" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<input type="checkbox"> FN-Other Required Licenses or Permits
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachOtherreq.body}" filename="{! attachOtherreq.name}" id="file10" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<br></br>
<apex:commandbutton value="Upload Required Documents" action="{! upload}"/>
<apex:commandButton value="Complete & Sign Required Documents"/>
</body>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller
public PageReference upload() {
//id1= ApexPages.CurrentPage().getParameters().get('id');
id1= complaince.id;
system.debug('## id' +id1);
Boolean errorOccured=false;
if(attachBis711 != null && String.isNotBlank(attachBis711.name)){
attachBis711.OwnerId = UserInfo.getUserId();
attachBis711.ParentId = +id1; // the record the file is attached to
attachBis711.IsPrivate = true;
try {
insert attachBis711;
} catch (DMLException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading GTS-BIS711'));
errorOccured = true;
}
}
Please help
Maximum view state size limit (135KB) exceeded. Actual view state size for this page was 146.86KB
<apex:page controller="GLADDDExtPortalCC" sidebar="false">
<apex:pagemessages />
<apex:sectionHeader title="Questionnaire" subtitle="Step 8 of 8"/>
<APEX:form >
<apex:pageBlock mode="edit">
<apex:pageBlockButtons >
<apex:commandButton value="Previous" action="{! step6}" style="background:#0070d2 !important; width:100px; color:white; padding: 5px;"/>
<apex:commandButton value="Save" action="{! save}" style="background:#0070d2 !important; width:100px; color:white; padding: 5px;"/>
<apex:commandButton value="Save and Next" action="{! step7}" style="background:#0070d2 !important; width:100px; color:white; padding: 5px;"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="References" columns="1">
<body>
<h1><u>GLADDD: Submission Document Checklist</u></h1>
<br></br>
<br></br>
<h1><u>Mandatory</u></h1>
<br></br>
<input type="checkbox"> GTS-BIS711
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachBis711.body}" filename="{! attachBis711.name}" id="file" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!-- <apex:commandButton value="Upload Required Documents" action="{! upload}"/> -->
<br></br>
<input type="checkbox"> CMP-Certification of Complaince
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachCertComp.body}" filename="{! attachCertComp.name}" id="file1" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!-- <apex:commandButton value="Upload Required Documents" action="{! upload}"/> -->
<br></br>
<input type="checkbox"> FN_DD Certification
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachDDcerti.body}" filename="{! attachDDcerti.name}" id="file2" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<br></br>
<h1><u>If Yes selected(A/D Questionnaire)</u></h1>
<br></br>
<input type="checkbox"> CMP-Anti-Corruption Policy
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachAntiCorr.body}" filename="{! attachAntiCorr.name}" id="file3" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<input type="checkbox"> CMP-Code of Conduct
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachCodeCond.body}" filename="{! attachCodeCond.name}" id="file4" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<br></br>
<h1><u>Non Mandatory</u></h1>
<br></br>
<input type="checkbox"> FN-Tax License
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachTaxLicen.body}" filename="{! attachTaxLicen.name}" id="file5" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<input type="checkbox"> FN-Bank Statement(Bank Reference Letter)
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachBankState.body}" filename="{! attachBankState.name}" id="file6" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<input type="checkbox"> FN-Medical Device Business Permit
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachMedicalDe.body}" filename="{! attachMedicalDe.name}" id="file7" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<input type="checkbox"> FN-Company Registration Certificate
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachCompReg.body}" filename="{! attachCompReg.name}" id="file8" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<input type="checkbox"> FN-Financial Statement
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachFinanStat.body}" filename="{! attachFinanStat.name}" id="file9" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<input type="checkbox"> FN-Other Required Licenses or Permits
</input>
<apex:pageBlockSectionItem >
<apex:outputLabel value="File" for="file"/>
<apex:inputFile value="{! attachOtherreq.body}" filename="{! attachOtherreq.name}" id="file10" accept=".pdf"/>
</apex:pageBlockSectionItem>
<!--apex:commandButton value="Upload Required Documents" action="{! upload}"/-->
<br></br>
<br></br>
<apex:commandbutton value="Upload Required Documents" action="{! upload}"/>
<apex:commandButton value="Complete & Sign Required Documents"/>
</body>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller
public PageReference upload() {
//id1= ApexPages.CurrentPage().getParameters().get('id');
id1= complaince.id;
system.debug('## id' +id1);
Boolean errorOccured=false;
if(attachBis711 != null && String.isNotBlank(attachBis711.name)){
attachBis711.OwnerId = UserInfo.getUserId();
attachBis711.ParentId = +id1; // the record the file is attached to
attachBis711.IsPrivate = true;
try {
insert attachBis711;
} catch (DMLException e) {
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading GTS-BIS711'));
errorOccured = true;
}
}
Please help
similar for other attachment properties.
Let me know, If this does not solve your problem.
Thanks