function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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/