0

Good day I am encountering the error below:

'LeadStandardController.customerName' Basically I want to upload a record that has already been created. Please find below my code:

VF Page

<apex:page tabStyle="Account" standardController="Lead" extensions="CIFController" docType="html-5.0" showHeader="false" sidebar="false">
<apex:form>
    <ul>
        <apex:outputPanel layout="block">
        <apex:pageBlock >
        <apex:outputPanel > 
            <apex:pageblocksection title="MAIN CONTACT DETAILS: INDIVIDUAL CONNECTED WITH THIS APPLICATION" collapsible="false"  >
                <apex:inputTextArea value="{!Customer_Name__c}" required="true" html-placeholder="Customer Name:"/>
                <apex:inputTextArea value="{!Licence_c}" required="true" html-placeholder="Licences - if any:"/>      
                <apex:inputTextArea value="{!Email_c}" required="true" html-placeholder="Email"/>
                <apex:inputTextArea value="{!Surname_and_First_Name__c}" required="true" html-placeholder="Surname and Name"/>
                <apex:inputTextArea value="{!Job_Title__c}" required="true" html-placeholder="Job Title"/>           
                <apex:inputTextArea value="{!Telephone_Number__c}" required="true" html-placeholder="Telephone Number"/> 
            </apex:pageblocksection>
            <apex:pageblocksection >
                <apex:inputTextArea value="{!Business_Profile__c}" required="true" html-placeholder="Business Profile:"/> 
            </apex:pageblocksection>            
            <apex:outputPanel >
                      <p style="color:#629DD1;font-family:Fauna One"><b>Attach a copy of the business letterhead and the identification document of the customer representative.</b></p>       
            </apex:outputPanel> 
            <apex:pageblocksection title="BUSINESS REGISTRATION & ID CARD STATUTORY DOCUMENTS" collapsible="false">  
              <apex:inputFile title="Identity Card" style="width:100%" id="fileToUpload1" value="{!idCardBody }" filename="{!idCardName }" />      
              <apex:inputFile title="Business Registration Document" style="width:100%" id="fileToUpload" value="{!documentBody }" filename="{!businessDocName }" /> 
            </apex:pageblocksection>
            </apex:outputPanel> 
            <apex:pageBlock >
              <apex:commandButton styleClass="submit" value="Submit    Application" action="{!UpdateRecord}"/>
            </apex:pageBlock>
        </apex:pageBlock>
        </apex:outputPanel>
    </ul>
</apex:form>

Apex Extension

  public class CIFController
  {
   public Lead leadDetail 
   {get;set;}
   public Id leadId
   {get;set;}
   //attachment Document name
   public string businessDocName 
   {get;set;}
  //attachment Document body
  public Blob documentBody 
  {get;set;} 
  //attachment ID name
  public string idCardName 
  {get;set;}
  //attachment ID body
  public Blob idCardBody 
  {get;set;} 
  //get the lead id record
  public CIFController(ApexPages.StandardController ctlr)
  {
     leadId = ctlr.getRecord().Id;     
  }
  //update the fields on the record 
  public PageReference UpdateRecord(){
      Id leadId ;
      //lead custom fields and definitions 
      leadDetail = [SELECT Customer_Name__c, Licence_c, Email_c, Surname_and_First_Name__c, Job_Title__c, Telephone_Number__c FROM Lead WHERE Id  =: leadid];

      PageReference pgRef;
      if((documentBody != null && businessDocName != null)||(idCardBody !=   null && idCardName != null))
      {
          Attachment businessDocument  = new Attachment();
          Attachment idDocument  = new Attachment();
           if(documentBody != null && businessDocName != null)
          {
              businessDocument.Body = documentBody;
              businessDocument.Name = businessDocName;
              businessDocument.ParentId = leadId;
              try
             {
                  if(idCardBody != null && idCardName != null)
                  { 
                      idDocument.Body = idCardBody;
                      idDocument.Name = idCardName;
                      idDocument.ParentId = leadId;
                  }
                  insert businessDocument;
                  insert idDocument;
              }catch(DMLException e)
              {
                  ApexPages.addMessage(new   ApexPages.message(ApexPages.severity.ERROR,'Error uploading attachment'));
                      return null;
              }
          }
          pgRef = new PageReference('http://thank.you/');
          pgRef.setRedirect(true);
          return pgRef;
      }   
      return null;
  }    
}

How can I fix it? Thank you in advance for the suggestions and assistance...

1 Answer 1

0

You can't directly refer the field . You need to add leadDetail before field name

<apex:pageblocksection title="MAIN CONTACT DETAILS: INDIVIDUAL CONNECTED WITH THIS APPLICATION" collapsible="false"  >
                <apex:inputTextArea value="{!leadDetail.Customer_Name__c}" required="true" html-placeholder="Customer Name:"/>
                <apex:inputTextArea value="{!leadDetail.Licence_c}" required="true" html-placeholder="Licences - if any:"/>      
                <apex:inputTextArea value="{!leadDetail.Email_c}" required="true" html-placeholder="Email"/>
                <apex:inputTextArea value="{!leadDetail.Surname_and_First_Name__c}" required="true" html-placeholder="Surname and Name"/>
                <apex:inputTextArea value="{!leadDetail.Job_Title__c}" required="true" html-placeholder="Job Title"/>           
                <apex:inputTextArea value="{!leadDetail.Telephone_Number__c}" required="true" html-placeholder="Telephone Number"/> 
            </apex:pageblocksection>
            <apex:pageblocksection >
                <apex:inputTextArea value="{!leadDetail.Business_Profile__c}" required="true" html-placeholder="Business Profile:"/> 
            </apex:pageblocksection> 
1
  • Thank you very much @Tushar, i had totally missed that. Thank you... Aug 22, 2016 at 10:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .