+ Start a Discussion
SFDCExplorerSFDCExplorer 

What is the purpose of "recordsetvar" attribute?

I have red in salesforce help pages that "recordsetvar" variable can be used to access data in the record collection. But I have never seen any vf page that is using "recordsetvar" as a variable to access the data in the record collection. If it is true ,can anybody let me know any example that is using this variable to access the record collection?
Best Answer chosen by SFDCExplorer
DebasisDebasis
Hi SFDCExplorer,

The recordSetVar attribute not only indicates that the page uses a list controller, it can indicates the variable name of the record collection. This variable can be used to access data in the record collection.
It is the in built salesforce functionality that comes with standard controller. 
It will display the salesforce pre-defined options for the selectoptions by the variable "listviewoptions".
And they internally manage the selected value(selectlist) with the variable "filterId".
This attribute indicates that VF page uses set oriented standard controller. The value of the attribute indicates name of the set of records passed to the page means collection records. This record set can be used in the expressions to return values for display on the page or to perform actions on set of records.
    For example given below VF page, if your page is using the standard accounts controller, and recordSetVar is set to "accounts", you could create a simple pageBlockTable of account records by doing the following:
This attribute indicates that VF page uses set oriented standard controller. The value of the attribute indicates name of the set of records passed to the page means collection records. This record set can be used in the expressions to return values for display on the page or to perform actions on set of records.
    For example given below VF page, if your page is using the standard accounts controller, and recordSetVar is set to "accounts", you could create a simple pageBlockTable of account records by doing the following:

check this visualforce page
<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!accounts}" var="a">
            <apex:column value="{!a.name}"/>
         </apex:pageBlockTable>
     </apex:pageBlock>
</apex:page>

Thanks,
Debasis

All Answers

DebasisDebasis
Hi SFDCExplorer,

The recordSetVar attribute not only indicates that the page uses a list controller, it can indicates the variable name of the record collection. This variable can be used to access data in the record collection.
It is the in built salesforce functionality that comes with standard controller. 
It will display the salesforce pre-defined options for the selectoptions by the variable "listviewoptions".
And they internally manage the selected value(selectlist) with the variable "filterId".
This attribute indicates that VF page uses set oriented standard controller. The value of the attribute indicates name of the set of records passed to the page means collection records. This record set can be used in the expressions to return values for display on the page or to perform actions on set of records.
    For example given below VF page, if your page is using the standard accounts controller, and recordSetVar is set to "accounts", you could create a simple pageBlockTable of account records by doing the following:
This attribute indicates that VF page uses set oriented standard controller. The value of the attribute indicates name of the set of records passed to the page means collection records. This record set can be used in the expressions to return values for display on the page or to perform actions on set of records.
    For example given below VF page, if your page is using the standard accounts controller, and recordSetVar is set to "accounts", you could create a simple pageBlockTable of account records by doing the following:

check this visualforce page
<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!accounts}" var="a">
            <apex:column value="{!a.name}"/>
         </apex:pageBlockTable>
     </apex:pageBlock>
</apex:page>

Thanks,
Debasis
This was selected as the best answer
Amit Chaudhary 8Amit Chaudhary 8
The recordSetVar attribute not only indicates that the page uses a list controller, it can indicates the variable name of the record collection. This variable can be used to access data in the record collection
Example 1:-
<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!accounts}" var="a">
            <apex:column value="{!a.name}"/>
         </apex:pageBlockTable>
     </apex:pageBlock>
</apex:page>
Example 2:-
<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
    <apex:pageBlock >
          <apex:repeat value="{!accounts}" var="a">
<apex:pageBlockSection title="{!a.name}"></apex:pageBlockSection>
  <apex:relatedList list="Contacts" subject="{!a.Id}"/>
<apex:relatedList list="Opportunities" subject="{!a.Id}" />
</apex:repeat>      
     </apex:pageBlock>
</apex:page>



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", you could create a simple pageBlockTable of account records by doing the following:
<apex:pageBlockTable value="{!accounts}"var="a"><apex:column value="{!a.name}"/></apex:pageBlockTable>
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_page.htm


Please check below post for more information
1)http://salesforce.stackexchange.com/questions/97423/what-is-recordsetvar-and-where-is-it-used


Let us know if this will help you

Thanks
Amit Chaudhary