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
Clay AshworthClay Ashworth 

Issue passing updated inputField values to Controller using actionFunction and param.

I am having an issue trying to pass inputField values from my VF page back to the controller using actionFunction with an onchange. The intent is that when the value in the inputField is changed by the user the new value is passed to the controller for processing.

As it stands now values for the inputFields are being passed but not the updated value of the field that was changed and triggered the onchange to fire. I have been over this for several hours and tried a few different methods of approaching this, none of which have been successful. Any help is appreciated.

VF Page:
<apex:pageBlockSection id="Detail" title="Product Detail">
    		<apex:inputField value="{!qli.Service_Location__c}" required="true"/> 		
    		<apex:inputField value="{!qli.Term__c}" required="true" label="Term (Months)"/> 
    		<apex:inputField value="{!qli.Service_Type__c}" required="true"/> 
    		<apex:inputField value="{!qli.Quantity}" required="true" id="quantity" onchange="updateQty();">
 				<apex:actionFunction name="updateQty" action="{!getdiscount}" rerender="listpricing" immediate="true">
					<apex:param name="xquantity" value="{!qli.Quantity}" assignTo="{!xquantity}"/>
					<apex:param name="xsalesMRC" value="{!qli.UnitPrice}" assignTo="{!xsalesMRC}"/>
					<apex:param name="xNRC" value="{!qli.NRC_is_Quantity_Sensitive__c}" assignTo="{!xNRC}"/> 
				</apex:actionFunction> 
			</apex:inputField>
</apex:pageBlockSection> 
<apex:pageBlockSection id="salesPricing" title="Sales Pricing">

    			<apex:inputField value="{!qli.UnitPrice}" id="CsalesMRC" label="Sales MRC" onchange="updateMRC();">
    			 	<apex:actionFunction name="updateMRC" action="{!getdiscount}" rerender="listpricing" immediate="true">
						<apex:param name="xquantity" value="{!qli.Quantity}" assignTo="{!xquantity}"/>
						<apex:param name="xsalesMRC" value="{!qli.UnitPrice}" assignTo="{!xsalesMRC}"/>
						<apex:param name="xNRC" value="{!qli.NRC_is_Quantity_Sensitive__c}" assignTo="{!xNRC}"/> 
					</apex:actionFunction> 
				</apex:inputField>	
    			<apex:inputField value="{!qli.NRC__c}" label="Sales NRC" required="true"/> 
    			<apex:outputField value="{!qli.TotalPrice}"/> 
    			<apex:outputField value="{!qli.Total_NRC__c}"/> 
    			<apex:outputField value="{!qli.Discount}" label="Discount from List"/>
    			<apex:inputField value="{!qli.NRC_is_Quantity_Sensitive__c}" onchange="updateNRC();">
    			 	<apex:actionFunction name="updateNRC" action="{!getdiscount}" rerender="listpricing" immediate="true">
						<apex:param name="xquantity" value="{!qli.Quantity}" assignTo="{!xquantity}"/>
						<apex:param name="xsalesMRC" value="{!qli.UnitPrice}" assignTo="{!xsalesMRC}"/>
						<apex:param name="xNRC" value="{!qli.NRC_is_Quantity_Sensitive__c}" assignTo="{!xNRC}"/>  
					</apex:actionFunction> 
    			</apex:inputField>
</apex:pageBlockSection>
<apex:pageBlockSection id="listpricing" title="List Pricing" >
</apex:pageBlockSection>



Controller Class:
 
public double quantity				{get; set;}
public decimal CsalesMRC			{get; set;}
public Boolean NRC 				{get; set;}

public void getDiscount() {
		//Get all variables from page
		string xNRC = ApexPages.currentPage().getParameters().get('xNRC');
			system.debug('@@@xNRC = ' + xNRC);
		NRC = boolean.valueOf(xNRC);	
			system.debug('@@@NRC = ' + NRC);
	
		string xSalesMRC = ApexPages.currentPage().getParameters().get('xsalesMRC');
			system.debug('@@@xSalesMRC = ' + xSalesMRC);
		CsalesMRC = double.valueOf(xSalesMRC);		
			system.debug('@@@CsalesMRC = ' + CsalesMRC);
						
		string xQuantity = ApexPages.currentPage().getParameters().get('xquantity');
			system.debug('@@@xQuantity = ' + xQuantity);
		quantity = decimal.valueOf(xQuantity);
			system.debug('@@@quantity = ' + quantity);
}

 
AshwaniAshwani
These action functions shoudn't work.

You are passing three params but, during on change call you are just calling "updateNRC()" [No parameters]. But expected method call must be "updateNRC(arg1, arg2, arg3)".
Calling without arguments this method is automatically becomes "updateNRC(null,null,null)". You will have to pass all values in methods equal to nmber of params you have for actionfunction.