function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Salesforce Test 5Salesforce Test 5 

How to override 135KB limit in Visual force page:urgent

Hi Guys

I am facing one standard limitation issue long time.i have created a page for file uploading which is working fine for me,but problem is when i am uploading more 135 KB file its showing 135KB exceed limitation.I have go through some blogspot and finaly used Transient key word but its showing same.....How to achieve this issue any idea....
 
public class NewSalesConfirmationExtension {
    public Purchase_Order__c purchaseOrder{get;set;}
    public Attachment attachment {get;set;}
    public boolean showC1RecordType {get;set;}
    public boolean showC2RecordType {get;set;} 
    
    private Id c1RecordTypeId; 
    private Id c2RecordTypeId;
    
    public NewSalesConfirmationExtension(ApexPages.StandardController controller) {
        c1RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C1').getRecordTypeId();
        c2RecordTypeId = Schema.SObjectType.Purchase_Order__c.getRecordTypeInfosByName().get('C2').getRecordTypeId();
        
        purchaseOrder = new Purchase_Order__c();
        purchaseOrder = (Purchase_Order__c)controller.getRecord();
        
        String isButtonClicked = Apexpages.currentPage().getParameters().get('setDefaultValues');
        if(isButtonClicked == 'true'){
            setDefaultValues();
        }
        
        showC1RecordType = false;
        showC2RecordType = false;
        attachment = new Attachment();
        
        
        if(purchaseOrder.RecordTypeId == c1RecordTypeId){
            showC1RecordType = true;
            showC2RecordType = false;
        }
        else if(purchaseOrder.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);     
        purchaseOrder.Opportunity__c = quote.Opportunity_Product_Detail__r.Opportunity__c;
        purchaseOrder.Quote__c = quote.id;
        purchaseOrder.Company__c = quote.Opportunity_Product_Detail__r.Opportunity__r.Account__c;
        
        if(quote.Record_type_name__c == 'C1'){
            purchaseOrder.RecordTypeId = c1RecordTypeId;
        }
        else {
            purchaseOrder.RecordTypeId = c2RecordTypeId;
        }
    }
    public PageReference save(){
        if(attachment.Body == null){
            Apexpages.addMessage(new Apexpages.Message(Apexpages.Severity.ERROR, 'Please upload recent Purchase Order  before saving the record'));
            return null;
        }
        else{
            try{
                insert purchaseOrder;
                
                attachment.OwnerId = UserInfo.getUserId();
                attachment.ParentId = purchaseOrder.id;
                insert attachment;
                
                return new PageReference('/'+purchaseOrder.id);
            }
            catch(DMLException e){
                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,e.getMessage()));
                return null;
            }
        }
    }
}

 
salesforce mesalesforce me
hi
<apex:page controller="CCW_UploadFileController">
 
  <apex:form >
 
        <apex:pageBlock title="File Upload" >
 
            <br/>
 
            Select file:&nbsp;
            <apex:inputFile value="{!tAttachment.Body}" filename="{!tAttachment.Name}" filesize="{!tAttachment.BodyLength}" contentType="{!tAttachment.ContentType}" />
            &nbsp;&nbsp;
            <apex:commandButton value="Attach" action="{!doUploadFile}"/>
 
            <br/><br/>
 
        </apex:pageBlock>
 
     </apex:form>
 
</apex:page>
public with sharing class CCW_UploadFileController {
 
    /*
    *   attachment
    */
    public Attachment tAttachment{get;set;}
 
    /*
    *   constructor
    */
    public CCW_UploadFileController(){
 
        //initialize attachment container
        this.tAttachment = new Attachment();
 
    }
 
    /*
    *   upload file
    */
    public void doUploadFile(){
 
        //create new instance of uploaded file
        Attachment a = this.tAttachment.clone(false, true, false, false);
        a.OwnerId = UserInfo.getUserId();
        //record attachment associated with
        a.ParentId = '001i0000005umv5';
 
        //clear body of uploaded file to remove from view state
        this.tAttachment.Body = null;
 
        //create the attachment
        Database.Insert(a);
 
    }
 
}
https://cloudclickware.wordpress.com/2013/05/22/file-upload-maximum-view-state-size-limit-135kb-exceeded/

http://sfdcsrini.blogspot.com/2014/06/what-is-maximum-view-state-size-limit.html

 
Salesforce Test 5Salesforce Test 5
Hi salesforce I have tried this but its not working for my requirement.I need to upload more than 135KB file in custom object.How it is possible.... Regards Mahee