1

I'm creating a VF page for Standard objects Order and Quote which will be a replacement for standard new record creation page layout. Since both objects have mandatory Account and Opportunity fields, I have added the same in my page (although they are not required).Now when I'm trying to save the record in both pages, it does not gets saved. I've also noticed that there is no lookup sign coming for Account, Contact and Opportunity. Please suggest.

Page for Order-

<apex:page standardController="Order" extensions="Orders" showHeader="true" tabStyle="Order" >
  <apex:form >   
   <apex:pageblock >
     <apex:pageBlockSection columns="2">
            <apex:inputText value="{!order.Account}"/>
            <apex:inputField value="{!order.name}"/>                
            <apex:inputField value="{!order.Opportunity}"/>
            <apex:inputField value="{!order.EffectiveDate}"/>
            <apex:inputField value="{!order.Type}"/>
            <apex:inputField value="{!order.ShipToContact}"/>                                              
        </apex:pageBlockSection>
    </apex:pageBlock>
  <apex:commandButton value="Save" action="{!dosave}"/>

Page for Quote-

<apex:page standardController="Quote" showHeader="true" >
  <apex:form >
<apex:pageblock >
     <apex:pageBlockSection columns="2">                
            <apex:inputField value="{!Quote.name}"/>                                
            <apex:inputField value="{!Quote.QuoteNumber}"/>
            <apex:inputField value="{!Quote.Status}"/>                
            <apex:inputField value="{!Quote.Account}"/>
            <apex:inputField value="{!Quote.Opportunity}"/>
            <apex:inputField value="{!Quote.Contact}"/>                                               
        </apex:pageBlockSection>
    </apex:pageBlock>
     <apex:commandButton value="Save" action="{!dosave}"/>
</apex:form>

Controller for Order-

  public class Orders
  { 
  public Order record{get;set;}
  public Orders(ApexPages.standardcontroller std)
  { record=(Order)std.getrecord();           

  }

public pagereference dosave()
  {
     upsert record;
     pagereference page=new pagereference('/apex/SalesOrder');
     return page;
  }       
}

Controller for Quote-

public class Quotes
 { 
  public Quote record{get;set;}
  public Quotes(ApexPages.standardcontroller std)
  { record=(Quote)std.getrecord();           

  }

public pagereference dosave()
  {
     upsert record;
     pagereference page=new pagereference('/apex/SalesQuote');
     return page;
  }    

}
4

You have used inputText instead of inputField. For lookup add Id in value. And you have to add all required fields in your vf page. Use the instance you created on your controller i.e. Record in your value as described below. The same you have to do for your other page.

-----Vf Page ----------

<apex:page standardController="Order" extensions="Orders" tabStyle="Order" >
  <apex:form >   
   <apex:pageblock >
     <apex:pageBlockSection columns="2" >
            <apex:inputField value="{!record.AccountId}"/>
            <apex:inputField value="{!record.name}"/>
            <apex:inputField value="{!record.Status}"/>               
            <apex:inputField value="{!record.OpportunityId}"/>
            <apex:inputField value="{!record.EffectiveDate}"/>
            <apex:inputField value="{!record.Type}"/>
            <apex:inputField value="{!record.ShipToContactId}"/>                                              
        </apex:pageBlockSection>
    </apex:pageBlock>
  <apex:commandButton value="Save" action="{!dosave}"/>
  </apex:form>
 </apex:page>

----Controller-----

public class Orders
  { 
  public Order record{get;set;}
  public Orders(ApexPages.standardcontroller std)
  { 
  //record=(Order)std.getrecord();
  record = new Order();           

  }

public pagereference dosave()
  {
     insert record;
     pagereference page=new pagereference('/apex/SalesOrder');
     return page;
  }       
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.