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
RuduRudu 

Hello guys i have to write the controller and create the Two VF pages..but i am facing issue in Additionally Contact page will provide ability to upload Contact photo.

Controller Class:-
public class newOpportunityController {

  
   Account account;
   Contact contact;
   
   public Account getAccount() {
      if(account == null) account = new Account();
      return account;
   }

   public Contact getContact() {
      if(contact == null) contact = new Contact();
      return contact;
   }

 
   public PageReference step1() {
      return Page.opptyStep1;
   }

   public PageReference step2() {
      return Page.opptyStep2;
   }

 
    public PageReference cancel() {
			PageReference opportunityPage = new ApexPages.StandardController(Contact).view();
			opportunityPage.setRedirect(true);
			return opportunityPage; 
    }

  
   public PageReference save() {

   
      account.phone = contact.phone;
      insert account;

      // Create the contact. Before inserting, use the id field
      // that's created once the account is inserted to create
      // the relationship between the contact and the account.
      contact.accountId = account.id;
      insert contact;

     

      PageReference opptyPage = new ApexPages.StandardController(Contact).view();
      opptyPage.setRedirect(true);

      return opptyPage;
   }
    public blob file { get; set; }
      public PageReference upload()
    {
      
        ContentVersion v = new ContentVersion();
        v.versionData =file;
        v.title = 'testing upload';
        v.pathOnClient ='/somepath.jpg / somepath.png';
        insert v;
        return new PageReference('/' + v.id);
    }

}




opptyStep1
<apex:page controller="newOpportunityController" tabStyle="Account">
  <script>
  function confirmCancel() {
      var isCancel = confirm("Are you sure you wish to cancel?");
      if (isCancel) return true;
      return false;
  }  
  </script>
  <apex:sectionHeader title="Edit Account" subtitle="New Account"/>
    <apex:form >
      <apex:pageBlock title="Account Information" mode="edit">

        <!-- The pageBlockButtons tag defines the buttons that appear at the top
             and bottom of the pageBlock. Like a facet, it can appear anywhere in
             a pageBlock, but always defines the button areas.-->
        <!-- The Next button contained in this pageBlockButtons area
             calls the step2 controller method, which returns a pageReference to
             the next step of the wizard. -->
        <apex:pageBlockButtons >
          <apex:commandButton action="{!step2}" value="Next"/>
          <apex:commandButton action="{!cancel}" value="Cancel" 
                              onclick="return confirmCancel()" immediate="true"/>
        </apex:pageBlockButtons>
          
      <apex:pageBlockSection title="Account Inpformation">

        <!-- Within a pageBlockSection, inputFields always display with their
             corresponding output label. -->
         
        <apex:inputField id="AccountName" value="{!account.Name}" required="true"/>
        <apex:inputField id="AccountType" value="{!account.Type}"/>
      </apex:pageBlockSection>
      <apex:pageBlockSection title="Address Information">
          <apex:inputField value="{!Account.BillingStreet}"/>
          <apex:inputField value="{!Account.BillingCity}"/>
            <apex:inputField value="{!Account.ShippingStreet}"  required="true"/>  
            <apex:inputField value="{!Account.ShippingCity	}" required="true"/>
           <apex:inputField value="{!Account.ShippingState}" required="true"/>
           <apex:inputField value="{!Account.ShippingPostalCode}" required="true"/>
           <apex:inputField value="{!Account.ShippingCountry}" required="true"/>
           </apex:pageBlockSection>
          <apex:pageBlockSection title="Additional Information">
          <apex:inputField value="{!Account.Website}"/>
          <apex:inputField value="{!Account.Industry}"/>
          <apex:inputField value="{!Account.Phone}"/>
            <apex:inputField value="{!Account.Fax}"/>
            <apex:inputField value="{!Account.Description}"/>
        
     </apex:pageBlockSection>
     
          
    </apex:pageBlock>
  </apex:form>
</apex:page>


opptyStep2:-
<apex:page controller="newOpportunityController" tabStyle="Contact">
  <script>
  function confirmCancel() {
      var isCancel = confirm("Are you sure you wish to cancel?");
      if (isCancel) return true;
  
     return false;
  }  
  </script>
  <apex:sectionHeader title="New Contact" subtitle="Step 2 of 3"/>
  <apex:form >
    <apex:pageBlock title="Contact Information" mode="edit">
      <apex:pageBlockButtons >
        <apex:commandButton action="{!step1}" value="Previous"/>
        <apex:commandButton action="{!Save}" value="Save"/>
        <apex:commandButton action="{!cancel}" value="Cancel" 
                            onclick="return confirmCancel()" immediate="true"/>
      </apex:pageBlockButtons>
     <apex:pageblocksection title="Contact Information">
     <apex:inputField value="{!Contact.FirstName}"/>
     <apex:inputField value="{!Contact.LastName}"/>
          <apex:inputField value="{!Contact.Department}"/>
          <apex:inputField value="{!Contact.Birthdate}"/>
          <apex:inputField value="{!Contact.Phone}"/>
          <apex:inputField value="{!Contact.MobilePhone}"/>
          <apex:inputField value="{!Contact.Email}"/>
         
            <apex:inputFile value="{!file}" />
 <apex:commandbutton action="{!upload}" value="upload" />


      </apex:pageblocksection>
    </apex:pageBlock>
  </apex:form>
</apex:page>

Requirment:-Create a custom VF Tab ‘Quick Create’. • Create a VF Page wizard. This wizard will have two pages. • First Page will let user enter Account details. Fields to be present on Account Page Wizard : Account Name(Mandatory), Account Type, Billing Address, Shipping Address(Mandatory), Website, Industry, Phone, Fax, Description • Second Page will let user enter Contact Details: Contact Name, Department, Birthdate, Phone, Mobile, Email. • Additionally Contact page will provide ability to upload Contact photo. • User should have ability to move between the first and second page of Wizard and values should remain intact. • Save button will be available only on the second page. On click of save first create Account record then create contact record and link it with Account. • When user will click on Next button of first page. Validation should be in place to ensure all mandatory fields are populated. Then only allow user to move to Contact Page for filling information.