+ Start a Discussion
Vijay Kumar Rebbala 11Vijay Kumar Rebbala 11 

Capture the inputfield value changes from Visualforce page into controller and update the record

<apex:page Controller="testctrl1">
    <apex:form >
    <apex:actionRegion >
        <apex:inputField value="{!updacc.Name}"/>
        <apex:inputField value="{!updacc.CustomerPriority__c}"/>
    </apex:actionRegion>
            <apex:commandButton action="{!customupdate}" value="Update" immediate="true"/>
    </apex:form>
</apex:page>



public class testctrl1{   
    public Account updacc{get; set;}
    public testctrl1() {
        updacc = [select Id, Name, CustomerPriority__c From Account where id = '001610000047HlW'];
    }
    public void customupdate(){
       update updacc;
    }
}

If the user change the input field value 'CustomerPriority__c' and click on Save. I need to update the record. How can I do that?

Thanks,
Vijay
Best Answer chosen by Vijay Kumar Rebbala 11
sandeep@Salesforcesandeep@Salesforce
Please take out "Immediate=true" attribute from your command button. Because of using it your setter will not work and no value goes inside of controller. 
 
<apex:page Controller="testctrl1">
    <apex:form >
    <apex:actionRegion >
        <apex:inputField value="{!updacc.Name}"/>
        <apex:inputField value="{!updacc.CustomerPriority__c}"/>
    </apex:actionRegion>
            <apex:commandButton action="{!customupdate}" value="Update" />
    </apex:form>
</apex:page>

Thanks
Sandeep Singhal
http://www.codespokes.com/