+ Start a Discussion
ThomasmThomasm 

Custom controll save button

I have a visualforce page that used a custom controller to pull a list from an object and offers inline editing.  I was trying to do a quicksave button like with standard controller but i am unable to.  How can add a quicksave to a custom controller

<apex:page controller="Scllist1">
<apex:form >
 <apex:pageblock title="Open Service Call Logs">
 <apex:pageblocksection >
 <apex:pageblockTable value="{!acts}" var="s">
 <apex:column value="{!s.name}"/>
 <apex:column headerValue="Status">
 <apex:inputfield value="{!s.Status__c}"/>
 </apex:column>
 </apex:pageblockTable>
 </apex:pageblocksection>
 </apex:pageblock> 
 </apex:form>
</apex:page>

here is the controller

public class Scllist1 {
    List<Service_call_log__C> acts =[Select Name, subject__c, status__C From Service_call_log__c where status__C<>'Closed'];
    
    public List<Service_Call_log__C> getacts() 
    {
    return acts;
     }
}
Best Answer chosen by Thomasm
Pramodh KumarPramodh Kumar
A small snippet for your scenario.
 
<!--vf page tag-->
<apex:pageBlockButtons >
     <apex:commandButton action="{!quicksave}" value="quicksave"/>
 </apex:pageBlockButtons>


//Quciksave method in your controller

     list<Service_call_log__c> updateList;
     public void quicksave(){
       updateList   = new list<Service_call_log__c>();
       for(Service_call_log__c acc: acts){
           updateList.add(acc);
       }
       update updateList;
     }

Thanks,
pRAMODH.

All Answers

Pramodh KumarPramodh Kumar
A small snippet for your scenario.
 
<!--vf page tag-->
<apex:pageBlockButtons >
     <apex:commandButton action="{!quicksave}" value="quicksave"/>
 </apex:pageBlockButtons>


//Quciksave method in your controller

     list<Service_call_log__c> updateList;
     public void quicksave(){
       updateList   = new list<Service_call_log__c>();
       for(Service_call_log__c acc: acts){
           updateList.add(acc);
       }
       update updateList;
     }

Thanks,
pRAMODH.
This was selected as the best answer
ThomasmThomasm
I added the code but once i edited the fieds and hit the quicksave button i recieved the following error


System.LimitException: Too many SOQL queries: 101
Error is in expression '{!quicksave}' in component <apex:commandButton> in page v1: Trigger.ServiceCallLogClosed: line 5, column 1
Trigger.ServiceCallLogClosed: line 5, column 1
Pramodh KumarPramodh Kumar
I think you have trigger on that object, see the trigger named ServiceCallLogClosed and check at the line 5