+ Start a Discussion
FernandFernand 

associate RecordSetVar with Save command

I created a visualforce page with a simple save action and it just works fine.
However when I added recordSetVar, the save/quicksave actions don't seems to work anymore.
<apex:page standardController="Account" recordSetVar="accounts">
    <apex:form >
        <apex:pageBlock >
        <apex:pageMessages />
        <apex:pageBlockSection >
            <apex:inputField value="{!account.name}"/>
            <apex:commandButton action="{!QUICKSAVE}" value="SAVE!"/>
        </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

can you please point out what did I miss?

 
Best Answer chosen by Fernand
nagendra 6989nagendra 6989
Hi Fernand Arioja 3,

When you create a visual force page with simple save action method it works fine, the reason is you are operating on only one recrord and save action method will save only one record at a time.

When you add "recordsetvar" what will happen is it will store set of records pertaining to that particular variable which you have defined for recordsetvar, so when it is storing multiple records in that variable(collection of records) and you are trying to save them at one shot it does'nt work.More or less recordsetvar is used to store multiple records and display them accordingly.It(recordsetvar) does'nt have anything to do with save and quicksave

Purpose of recordsetvar

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:page standardController="Account" recordSetVar="accounts">
 <apex:dataList var="a" value="{!accounts}" type="1">
 {!a.name}
 </apex:dataList>
 </apex:page>

Above displays all account with number.
As we make use of recordset var it helps in storing all the account records in "accounts" variable and by using the datalist component we are just displaying them accordingly in the vf page.But when you use save and quicksave methods simultaneously when recordsetvar is in use it does'nt work and redirects back you to the home page.

Please let me know if it helps you..............

Thanks & Regards,
Nagendra.P
9848950830

 

All Answers

Nitin SharmaNitin Sharma
Use only SAVE in action instead of QUICKSAVE. It work fine.

Thanks,
Nitin Sharma
Chandu017Chandu017
Hi,
It is still not working with the action save when using recordsetvar. Please let me know the issue.
FernandFernand
@nitin
nope, both save or quicksave command doesn't work.
 
nagendra 6989nagendra 6989
Hi Fernand Arioja 3,

When you create a visual force page with simple save action method it works fine, the reason is you are operating on only one recrord and save action method will save only one record at a time.

When you add "recordsetvar" what will happen is it will store set of records pertaining to that particular variable which you have defined for recordsetvar, so when it is storing multiple records in that variable(collection of records) and you are trying to save them at one shot it does'nt work.More or less recordsetvar is used to store multiple records and display them accordingly.It(recordsetvar) does'nt have anything to do with save and quicksave

Purpose of recordsetvar

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:page standardController="Account" recordSetVar="accounts">
 <apex:dataList var="a" value="{!accounts}" type="1">
 {!a.name}
 </apex:dataList>
 </apex:page>

Above displays all account with number.
As we make use of recordset var it helps in storing all the account records in "accounts" variable and by using the datalist component we are just displaying them accordingly in the vf page.But when you use save and quicksave methods simultaneously when recordsetvar is in use it does'nt work and redirects back you to the home page.

Please let me know if it helps you..............

Thanks & Regards,
Nagendra.P
9848950830

 
This was selected as the best answer
FernandFernand
@nagedra,

I think your answer explains it.
I was just confused while studying this documentation:
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_sosc_actions.htm

Thank You!
nagendra 6989nagendra 6989
@FearNOne,

Sounds really good if it helped you.................

Best Regards,
Nagendra!