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

Why does action support onchnage event refer to original value of field not the changed value?

I have an on change event on my VF page which fires OK when the field is changed but the code in the controller still appears to be looking at the original value in the field rather than the the changed value - I can tell this from System.debugs I have used.. Should I be passing a parameter in some way or am I just not using the correct field in the action=

Controller Code snippet :
         public void onReasonForOrderLineChange() {     
            if (null == orderLineItem.Free_of_Charge_reason__c){
                orderLineItem.Free_of_Charge__c = False;
            } else {
                //if (orderLineItem.Free_of_Charge_reason__c.substring(0,3) == 'FOC') {
                if (orderLineItem.Free_of_Charge_reason__c.left(3) == 'FOC') {
                    orderLineItem.Free_of_Charge__c = True;
                    orderLineItem.Price_Charged__c = 0;
                } else {
                    orderLineItem.Free_of_Charge__c = False;
                    orderLineItem.Price_Charged__c = orderLineItem.Standard_Price__c;

Visual Force Page
   <apex:pageBlockSectionItem >
   <apex:outputLabel value="{!$ObjectType.Order_Line_Item__c.fields.Free_of_Charge_reason__c.label}" />
         <apex:outputPanel id="LineReason">
             <apex:inputField rendered="{!isFOCEditable}" value="{!lineItem.orderLineItem.Free_of_Charge_reason__c}" >
                  <apex:actionSupport event="onchange" action="{!lineItem.onReasonForOrderLineChange}" rerender="lineItemsPane, orderTotal" status="overlayStatus">
             <apex:outputField value="{!lineItem.orderLineItem.Free_of_Charge_reason__c}" rendered="{!isFOCEditable}"/>