You need to sign in to do that
Don't have an account?
Salesforce Test 5
Maximum view state size limit (135KB) exceeded in apex class
Hi
I have created a class for uploading file.but when i am uplaoding any file more than 135KB its showing Maximum view state size limit (135KB) exceeded .how to overcome this..
I have created a class for uploading file.but when i am uplaoding any file more than 135KB its showing Maximum view state size limit (135KB) exceeded .how to overcome this..
public class Confirmation { public Order__c Order{get;set;} public Attachment attachment {get;set;} public boolean showC1RecordType {get;set;} public boolean showC2RecordType {get;set;} private Id c1RecordTypeId; private Id c2RecordTypeId; public Confirmation(ApexPages.StandardController controller) { c1RecordTypeId = Schema.SObjectType.Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId(); c2RecordTypeId = Schema.SObjectType.Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId(); Order = new Order__c(); Order = (Order__c)controller.getRecord(); String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues'); if(isButtonClicked == 'true'){ setDefaultValues(); } showC1RecordType = false; showC2RecordType = false; attachment = new Attachment(); if(Order.RecordTypeId == c1RecordTypeId){ showC1RecordType = true; showC2RecordType = false; } else if(Order.RecordTypeId == c2RecordTypeId){ showC1RecordType = false; showC2RecordType = true; } } public void setDefaultValues(){ String quoteId = Apexpages.currentPage().getParameters().get('quoteId'); Quote__c quote = [Select o.id, o.name, o.Quantity_formula__c, o.Opportunity_Product_Detail__r.Opportunity__c, o.Opportunity__c, o.Record_type_name__c,o.Company_Name__c,Opportunity_Product_Detail__r.Opportunity__r.Account__c from Quote__c o WHERE O.id=:quoteId]; //system.assert(false,quote); Order.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c; Order.Quote__c = quote.id; Order.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c; if(quote.Record_type_name__c == 'C1'){ Order.RecordTypeId = c1RecordTypeId; } else { Order.RecordTypeId = c2RecordTypeId; } } public PageReference save(){ if(attachment.Body == null){ Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, ' record')); return null; } else{ try{ insert Order; attachment.OwnerId = UserInfo.getUserId(); attachment.ParentId = Order.id; insert attachment; return new PageReference('/'+Order.id); } catch(DMLException e){ ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage())); return null; } } } }
I have modified your class, I just added constructor and initilized you object.
NOTE: I have not tested this.Just test it and let me know if you face any more issues.
Its showing same error...
I have problem is when i am uploading file more than 135KB its showing error.....