I am assigning value of one Input field to two variables-'UserResponsibleA and UserResponsibleB through <apex:param> and both are returning NULL values to controller. Here Responsible__c is a User Lookup field. Can you please check where is the problem.Any help will be highly appreciated.

VF Page:

function callActionMethod(){ var txtVal1 = document.getElementById("{!$Component.frm.val1}").value; var txtVal2 = document.getElementById("{!$Component.frm.val2}").value; echo(txtVal1,txtVal2 ); }
<apex:form id="frm">
    <apex:commandButton value="Save" action="{!saveResponsible}" onclick="callActionMethod()"/>
        <apex:inputField value="{!Responsible__c.Responsible__c}"  id="val1"/>
        <apex:inputField value="{!Responsible__c.Responsible__c}"  id="val2"/>
        <apex:actionFunction action="{!saveResponsible}" name="echo" reRender="">
            <apex:param name="UserResponsibleA" value="{!UserResponsibleA}" />
            <apex:param name="UserResponsibleB"  value="{!UserResponsibleB}" />           


 public with sharing class WorkPlanAddResponsibleVFPExtension{  
    public Id UserResponsibleA{get;set;}  
    public Id UserResponsibleB{get;set;}  
    public WorkPlanAddResponsibleVFPExtension(ApexPages.Standardcontroller std){  
        UserResponsibleList = new List<Id>();  
    public void saveResponsible(){  
        UserResponsibleA = ApexPages.currentPage().getParameters().get('UserResponsibleA');
        UserResponsibleB = ApexPages.currentPage().getParameters().get('UserResponsibleB');
  • is your javascript variable fetching values ? Commented Dec 12, 2014 at 3:49
  • Also you will need to provide Id to form as frm .Thats important I believe Commented Dec 12, 2014 at 3:50
  • I have edited code and its still not working:(.See the edited code above. Commented Dec 12, 2014 at 7:06

2 Answers 2


There's a quirk with <apex:actionFunction> in that it won't pass any parameters (i.e. the actual generated javascript function takes no parameters) unless you include a rerender attribute. That can be blank, so this might do the trick:

<apex:actionFunction action="{!saveResponsible}" name="echo" rerender="">

That said, I've rarely had luck using assignTo and tend to fall back on retrieving the parameters directly in code, for example:

String firstParam = ApexPages.CurrentPage().GetParameters().Get('firstParam');

Try using this soluntion. I think you are not assigning value to these two variables

<apex:actionFunction action="{!saveResponsible}" name="echo" reRender="">
     <apex:param name="UserResponsibleA" assignTo="{!UserResponsibleA}" value = ""/>
     <apex:param name="UserResponsibleB"  assignTo="{!UserResponsibleB}" value = ""/>           

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .