title: Update quantity of multiple opportunity line items on single Visualforce page
body: <p>I have a visualforce page that displays on the Opportunity page layout inline. The goal is to display each opportunity line item (OLI) that is associated with the opportunity, with a quantity inputfield. I need to be able to change the quantity of the OLI from the VF page. I have a controller that is extended off the standard opportunity controller and everything displays correctly, but when I try to save with my custom save method, the page refreshes and the changes to the fields are not updated. Any help is appreciated!</p>
  
  <p>VF PAGE:</p>
  
  <pre><code>&lt;apex:page standardController="Opportunity" extensions="OLIController"&gt;
  &lt;apex:form &gt;
  &lt;apex:pageBlock title="Opportunity Products"&gt;
  
  
  
      &lt;apex:pageBlockTable var="OLI" value="{!OLIs}" id="newProduct"&gt;
          &lt;apex:column value="{!OLI.name}"/&gt;
          &lt;apex:column headerValue="Quantity"&gt;
  
              &lt;apex:inputfield id="Quantity" value="{!OLI.Quantity}"/&gt;
  
          &lt;/apex:column&gt;
  
      &lt;/apex:pageBlockTable&gt;
  
      &lt;apex:pageBlockButtons &gt;
          &lt;apex:commandButton value="Save" action="{!saveIt}" immediate="false"/&gt;
      &lt;/apex:pageBlockButtons&gt;
  
  &lt;/apex:pageBlock&gt;
  &lt;/apex:form&gt;
  </code></pre>
  
  <p></p>
  
  <p>CONTROLLER:
  public with sharing class OLIController {</p>
  
  <pre><code>public ApexPages.StandardController sc;
  public Opportunity Opp {get;set;}
  private Map&lt;Id, OpportunityLineItem&gt; oliItems;
  public List&lt;OpportunityLineItem&gt; OLIlist2 {get ;set;}
  
  public OLIController(ApexPages.StandardController sc) { 
  this.Opp = (Opportunity)sc.getRecord();
  
  }
  
  
  public List&lt;OpportunityLineItem&gt; getOLIs() {
  
      List&lt;OpportunityLineItem&gt; OLIlist2 = [Select Name, ID, Quantity, OpportunityId FROM OpportunityLineItem WHERE OpportunityId =:Opp.Id];
  
      return OLIlist2;
  
  }
  public PageReference saveIt() {
      List&lt;OpportunityLineItem&gt; listOLI = getOLIs();
  
      update listOLI;
  
      return null;
  
  }
  </code></pre>
  
  <p>}</p>