• metacube_rahul
  • NEWBIE
  • 0 Points
  • Member since 2009

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

Following is the sample code which i am using to save maximum of 10 attachments at a time.

But whenever the size of the attachments gets larger the page displays the view state error message

For smaller size attachments the code works perfectly but whenever the size of any attachment increases

, the salesforce internal limit error occurs for viewstate.(128K) 

 

VF Page 

-------------------------------------------------------------

<apex:page controller="ReAttachmentController">

<apex:form >
<apex:pageMessages />
 <apex:repeat value="{!aList}" var="a">
   <apex:inputFile style="width:500px" value="{!a.body}" filesize="{!a.BodyLength}" filename="{!a.name}"/>
 </apex:repeat>
 

 <apex:commandButton value="Attach" action="{!doAttach}"/>
</apex:form>
</apex:page>

 

 

 

APEX CODE

--------------------------------

 

public class ReAttachmentController {
  public List<Attachment> aList{get;set;} 
  private String caseId = '50040000007GIsV'; 
  public ReAttachmentController(){
       aList = new List<Attachment>();
       for(Integer attachmentNos = 0 ; attachmentNos < 10; attachmentNos++){
             Attachment attach = new Attachment();
             aList.add(attach);
       }
  } 
  public boolean validateAttachments(){
        boolean returnValue = true;
        for(Attachment ab : aList){
              if(ab.body == null){
                   returnValue = false;
              }
        }       
        return returnValue;
  }
   
  public PageReference doAttach(){
      List<Attachment> lstToAttach = new List<Attachment>();
      boolean returnValue = validateAttachments();
         if(returnValue){
               for(Attachment ab : aList){
                    ab.parentId = caseId;
                    lstToAttach.add(ab);
               }
               insert lstToAttach;
               for(Attachment ab : aList){
                    ab.body = null;
               }
              
               return null;
         }else{
              return null;
         }             
  }
}

has anyone successfully integrated a flex upload control with force.com or salesforce.com, I am trying to implement a flex control for file upload (case attachment), please let me know 

 

thanks for your help

 

url to swfupload: http://swfupload.org/