I have a VF page to update couple of fields on the Opportunity record, it is a simple VF Page like below
<apex:page standardController="Opportunity" extensions="Opportunity_UpdExt" docType="html-5.0" sidebar="true" lightningstylesheets="true">
<apex:form >
<apex:pageBlock >
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlockSection title="Interests" columns="1">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Select Type" for="typeSel"></apex:outputLabel>
<apex:inputField value="{!oppRec.Type__c}" id="typeSel"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel value="Interest"/>
<apex:inputText value="{!oppRec.Interest__c}" />
</apex:pageBlockSectionItem>
<apex:commandButton value="Save" style="margin-left:500px;" action="{!finalUpdates}" />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
And the Controller Extension is like
public class Opportunity_UpdExt{
public Opportunity oppRec{get;set;}
public Opportunity currentRecord;
public Opportunity_UpdExt(ApexPages.StandardController controller) {
Id currentRecId=((Opportunity)controller.getRecord()).Id;
oppRec= new opportunity();
currentRecord=[SELECT id,Type__c, Interest__c FROM Opportunity WHERE id=:currentRecId];
oppRec = [SELECT id,Type__c, Interest__c FROM Opportunity WHERE id=:currentRecId];
}
public pagereference finalupdates(){
currentRecord.Type__c= oppRec.Type__c;
currentRecord.Interest__c= oppRec.Interest__c;
update currentRecord;
pagereference pageRef= new pagereference('/apex/Opportunity_Upd?id='+currentrecord.Id);
pageRef.setRedirect(true);
return pageRef;
}}
When I hit save the page is refreshed, but I was hoping two fields Type__c and Interest__c will be updated on the records with what was choosen on VF page. But when I query like these two fields are still blank even after executing VF Page, what am I missing here with respect to Updating the record