Friday, October 11, 2013

Editing Multiple Records at a Time using the RecordSetVar

Scenario:

         You want to edit multiple records at a time ,Don't worry .Salesforce also provided Standard List Controllers(RecordSetVar) along with Standard ,Custom and Extension Controllers.By using RecordSetVar we can achieve it.

  RecordSetVar:
       This attribute indicates that the page uses a set-oriented standard controller. The value of the attribute indicates the name of the set of records passed to the page. This record set can be used in expressions to return values for display on the page or to perform actions on the set of records. For example, if your page is using the standard accounts controller, and recordSetVar is set to "accounts". 

Standard list controllers can be used with the following objects:
  • Account
  • Asset
  • Campaign
  • Case
  • Contact
  • Contract
  • Idea
  • Lead
  • Opportunity
  • Order
  • Product2
  • Solution
  • User
  • Custom objects

VisualForce Page:
<apex:page standardController="Opportunity" 
           recordSetVar="opportunities"
           tabStyle="Opportunity" sidebar="false">
  <apex:form >
    <apex:pageBlock >
      <apex:pageMessages />
      <apex:pageBlockButtons >
        <apex:commandButton value="Save" 
                            action="{!save}"/>
      </apex:pageBlockButtons>
      <apex:pageBlockTable value="{!opportunities}" 
                           var="opp">
        <apex:column HeaderValue="Oppty Name">
          <apex:inputField value="{!opp.name}"/> 
        </apex:column>
        
        <apex:column headerValue="Stage">
          <apex:inputField value="{!opp.stageName}"/>
        </apex:column>
        <apex:column headerValue="Close Date">
          <apex:inputField value="{!opp.closeDate}"/>
        </apex:column>
      </apex:pageBlockTable>      
    </apex:pageBlock>
  </apex:form>
</apex:page>
 
Note:
    By default the RecordSetVar only displays 20 records at a time.If you want change 
the number of records displayed you can use the extension controller to set the size.
 
ScreenShots: 

Before changing the AB oppty stage from NeedAnalysis to ProposalPriceQuote


After changing the AB oppty stage from NeedAnalysis to ProposalPriceQuote

 






No comments: