• Geoffrey Lamb
  • NEWBIE
  • 10 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
I have been using a basic upload method for about a year on a couple of different custom visualforce pages and it's been working successfully.

I am developing my first component and unfortunately, this same upload method is not working, nothing gets uploaded. When debugged, the body and name for the attachment are returning "null."

If my inputFile is located directly on a normal visualforce page, and my method on its controller, no problems. When I call it anywhere inside of this component, using the component's controller, the attachment.body and attachment.name fields return null. It's probably worth mentioning, that this input field is located inside of two repeating section. First, it loops through parent opportunities. And then for each parent, it creates and then loops through up to 4 possible attachment uploads. I have it set up so that the controller and page always creates all four of them, then they are hidden by jQuery. For the record, this repeat method works inside of my other VF pages. If I put it inside of a repeating opportunity loop on a component, it fails.

Then, I have an associated problem because even if I could get the body to NOT be null at upload, the system can't tell which parent opportunity to attach it to. I would like to simply pass the index of the parent and then get it by that number. But VF hate me, and won't let me pass anything it seems. If I try to do it as shown below, I am forced to add a rerender attribute. If i do that, I am told that I'm not allowed due to the inputFile field.

What’s going on, can someone help me please? I've looked everywhere, for days. I need to know how to upload on a component, inside of two repeat loops. And then, how to pass the index of the parent Opportunity so that the controller knows where to attach the document. I'm still new at all of this so hopefully, this might be something easy? Thanks so much for your help!

PS: The relevant code is below... I can post the entire thing if someone feels that would be helpful. Thanks again!
 
<!-- ==============  VISUALFORCE COMPONENT ============ -->
         <apex:repeat id="attRepeat" value="{!newAttachments}" var="a" >
                <tr id="upTable-{!indexNo}-{!attIndex}" class="upTable-Row">
                    <td class="upTable-DataLeft">
                        <apex:pageBlockSection id="pbsBrowse">
                            <apex:pageBlockSectionItem id="pbsiBrowse">
                                  <apex:inputFile id="browseBtn" styleClass="browseBtn" value="{!filebody}" filename="{!filename}"/>
                                
                            </apex:pageBlockSectionItem>
                        </apex:pageblocksection>
                    </td>
                </tr>
          </apex:repeat>

                
                    <apex:commandButton id="upBtn" styleClass="upBtn" action="{!upload}"  status="status" value="Upload Documents">
                        <apex:param name="indexOfOpportunity" value="{!o.indexNo}" assignTo="{!upIndex}" /> <!-- this won't pass either -->
                    </apex:commandButton>

<!-- ================ CONTROLLER ======================= -->

public class offerProController{


public List<Attachment> newAttachments {get; set;}


public offerProController(){
    
   for(Integer attsInList = 0 ; attsInList < 4 ; attsInList++){ // the '4' will be a variable after all is working
        newAttachments = new List<Attachment>{new Attachment()}; //instantiate list of 4 attachments for uploaded docs
   }
         
    }

public PageReference upload() {
    
           i = integer.valueof(Apexpages.currentPage().getParameters().get('indexOfOpportunity'));  // this variable won't pass
           offer = myOpportunityList.get(i)      

            for(attachment a : newAttachments){
            
            system.debug('#d attBody and name are: '+a.Body+' and ' + a.Name); // both null
            a.ParentId = offer.Id; // the Opportunity 
            try {
              insert a;
              return newPage;
            } catch (DMLException e) {
              ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
              return null;
            } finally {
              a = new Attachment(); 
              
            }
            ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Attachment uploaded successfully'));
            return newPage;
        }return null;
    }

}



 
I recently installed EchoSign for Salesforce and finally have things up and running with my users being able to send documents with a single click. Now, I need to take it one step further and figure out a way to send a contract without user interaction, at the time a record (Lead) is created. 

Adobe talks about workflows in thier marketing but offers no obvious direction as to how to go about setting them up. As far as I can tell, this is not something which is a part of standard workflows so it sounds like I'm going to have to write another trigger??

Well, I've written a few triggers in the past but I am far from an expert. I can do it, I just need something to show me the way... I would appreciate any links or code snippets that anyone could offer. I'm sort of lost at this point and Adobe help & support is basically non-existent.

Thank you!

PS: I know how to find the basic Salesforce help guides on Apex Triggers - I need something specific to EchoSign. Thanks!
I recently installed EchoSign for Salesforce and finally have things up and running with my users being able to send documents with a single click. Now, I need to take it one step further and figure out a way to send a contract without user interaction, at the time a record (Lead) is created. 

Adobe talks about workflows in thier marketing but offers no obvious direction as to how to go about setting them up. As far as I can tell, this is not something which is a part of standard workflows so it sounds like I'm going to have to write another trigger??

Well, I've written a few triggers in the past but I am far from an expert. I can do it, I just need something to show me the way... I would appreciate any links or code snippets that anyone could offer. I'm sort of lost at this point and Adobe help & support is basically non-existent.

Thank you!

PS: I know how to find the basic Salesforce help guides on Apex Triggers - I need something specific to EchoSign. Thanks!
I recently installed EchoSign for Salesforce and finally have things up and running with my users being able to send documents with a single click. Now, I need to take it one step further and figure out a way to send a contract without user interaction, at the time a record (Lead) is created. 

Adobe talks about workflows in thier marketing but offers no obvious direction as to how to go about setting them up. As far as I can tell, this is not something which is a part of standard workflows so it sounds like I'm going to have to write another trigger??

Well, I've written a few triggers in the past but I am far from an expert. I can do it, I just need something to show me the way... I would appreciate any links or code snippets that anyone could offer. I'm sort of lost at this point and Adobe help & support is basically non-existent.

Thank you!

PS: I know how to find the basic Salesforce help guides on Apex Triggers - I need something specific to EchoSign. Thanks!