You need to sign in to do that
Don't have an account?
deepakp
saving only changed records for mass update VF page
I have written VF page which allows user to edit multiple records.
In save method in my controller, I am calling update oppportunityList.
This saves all records.
I want to save only records that have been changed. Is there any standard functionality in visualforce to detect only changed records.
<apex:inputField value="{!opp.Manager_Commit__c}"/>
</apex:column>
<apex:column headerValue="Manager Commit Comments">
<apex:inputField value="{!opp.Manager_Commit_Comments__c}"/>
</apex:column>
<apex:column value="{!opp.Probability}"/>
<apex:column value="{!opp.StageName}"/>
<apex:column value="{!opp.CloseDate}"/>
<apex:column value="{!opp.Owner.Name}"/>
<apex:column value="{!opp.Account.Name}"/>
<apex:column value="{!opp.Name}"/>
<apex:column value="{!opp.Fulfillment_Partner__c}"/>
<apex:column value="{!opp.Amount}"/>
</apex:pageBlockTable>
try {
changedOppList=new List<Opportunity>();
for ( Opportunity o: oppList) {
Opportunity o2=origOppMap.get(o.Id);
if ( o2 != null &&
(o2.Manager_Commit__c != o.Manager_Commit__c ||
o2.Manager_Commit_Comments__c != o.Manager_Commit_Comments__c) ) {
changedOppList.add(o);
}
}
update changedOppList;
} catch(DmlException ex){
ApexPages.addMessages(ex);
}
return null;
}
If you change the binding to "{!opportunities}" instead of "{!selected}" and call the page directly it will operate on all the results of the last selected view/filter.