Trouble with Action Support

Currently, I have been very successful with my page until I ran into a snag with my action:support tag.

I simply need to collect an Id, collected on the a form, then based on that Id, alter a Boolean for rendering purposes.

However, the value being bound is not being set or captured. Even more odd is that when I set immediate to true, the Id parameter called PossibleWhoId is being populated with a null value. As for if it is false, it doesn't even show up in ViewState.

Needless to say, there is a slight anomaly here.

The VisualForce Code

<apex:inputField value="{!Task[TaskField]}" required="{!TaskField.Required}" id="Who">
    <apex:actionSupport event="onchange" reRender="TaskPageBlockButtons" id="Name" action="{!DisableOrEnableAddOfficeContactButton}" immediate="true">
        <apex:param name="PossibleWho" assignTo="{!PossibleWhoId}" value="{!Task[TaskField]}"/>

The Apex Code

public Id PossibleWhoId { get; set; }
public PageReference DisableOrEnableAddOfficeContactButton()
    this.IsNotPrimaryContact = this.CurrentTask.WhoId == null 
        ||  this.CurrentTask.WhoId.getsObjectType().getDescribe().getName() != 'Contact'; 
    return null;
  • Without the immediate=true but with debug log enabled - are you sure you don't see the setter of PossibleWhoId being called in the debug log?
    – eyescream
    Commented Dec 24, 2013 at 23:06
  • I see what is happening. When I have immediate disabled, my check will only work when required fields are there. The error messages are getting swallowed -_- . However, this is not the behaviour I am looking for. I am trying to implement the good ol' action:region but am having difficulty nailing it. Commented Dec 24, 2013 at 23:12
  • 1
    Try my sample: salesforce.stackexchange.com/a/22216. Should be straightforward, just wrap with AR only the part of the form that you really have to submit. Or do the proper actionFunction where you're in full control of the params because you set them with a bit of JS (they can take params too).
    – eyescream
    Commented Dec 24, 2013 at 23:18
  • I tried using the action:region and it did not work at all. I believe it is because the apex:inputField is within a repeat tag - iterating through a field set. Plus, as soon as I add it, it completely breaks the layout - even when I wrap it with a apex:pageBlockSectionItem. I was attempting to collect the information via a JS function but was having difficulty with my selectors. I have never had to use it, so pardon my inexperience here. Commented Dec 25, 2013 at 1:43

1 Answer 1


Okay, after some guidance from eyescream, I came up with the following:

Using a suggestion found on this developerforce article and some off the wall advice. I came up with a decent but hacky solution.

Using the document.getElementById function, I was able to pass parameters like so:

In VisualForce

<apex:inputField value="{!Task[TaskField]}" required="{!TaskField.Required}" id="Who"
onchange="AssignNewWhoId((document.getElementById('{!$Component.Who}' + '_lkid')).value)"/>

I then, took advantage of this via an apex:actionfunction:

More VisualForce

<apex:actionFunction name="AssignNewWhoId" action="{!DisableOrEnableAddOfficeContactButton}" reRender="AddOfficeContactButtonTop, AddOfficeContactButtonBottom" immediate="true">
    <apex:param value="" name="NewWhoId"/>

Now that I was able to do that. I simply assigned the collected Id within my DisableOrEnableAddOfficeContactButton method:

this.CurrentTask.WhoId = Apexpages.currentPage().getParameters().get('NewWhoId');

That's all she wrote.

You must log in to answer this question.

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