+ Start a Discussion
ColinKenworthy2ColinKenworthy2 

Dependent Multi-select Picklist breaks in VF pages

If you make a multi-select picklist dependent on a picklist then use them in a VF page the left/right arrows will vanish as soon as you perform an action method.

e.g. create a custom object called MSP. Now on object MSP__c create a required text field, a picklist (2 or 3 values) and a multi-select picklist (4 or 5 values).

 

Field Label       API Name             Data Type
First Name        First_Name__c        Text(25) - required to save record
Master Picklist   Master_Picklist__c   Picklist
Test MSP          Test_MSP__c          Picklist (Multi-Select)

 In the MSP tab create a record.

Create the following VF page and Class (extensions controller)

 

public class MSP_EXT {

    public MSP__c MSPrec {get; set;}
    
    public MSP_EXT(ApexPages.StandardController controller) {
        MSPrec = (MSP__c) controller.getRecord();
    }
    
    public PageReference mySave() {
        update MSPrec;
        return null;
    }
}

VF page testMSP

 

<apex:page id="page1" standardController="MSP__c" extensions="MSP_EXT" >
    <apex:form id="form1">
        <apex:pageBlock id="pb1">

            <apex:pageBlockButtons id="pbb1" location="both">
                <apex:commandButton id="btn1" value="Save" action="{!mySave}"/>
            </apex:pageBlockButtons>

            <apex:pageBlockSection id="pbs1">

                <apex:inputField id="inp1" value="{!MSP__c.First_Name__c}"/>
                <apex:inputField id="inp2" value="{!MSP__c.Test_MSP__c}"/>
                <apex:inputField id="inp3" value="{!MSP__c.Master_Picklist__c}"/>

            </apex:pageBlockSection>

            <apex:pageMessages id="msgs1"/>

        </apex:pageBlock>

    </apex:form>
</apex:page>

So now try your apex page with the record you created:    yourInstance.salesforce.com/apex/testMSP?id=yourRecordId

 

 

Now save your record with and without a value in the required text field - no problems right? Everything works fine in the VF page and the Standard page.

 

Now with the Field Dependencies button make the multi-select picklist dependent on the picklist and make a few dependent values.

In the MSP Tab the Standard page works fine trying to edit the record with or without a value in the text field.

Go to the VF page again and whether there is a value in the text field or not, when you click the button the multi-select picklists left and right arrows vanish. (VF sends them with a display:none style attribute).

 

 

jwhartfieldjwhartfield

I stumbled upon this same problem just today.   Did you figure out a clever workaround for it or log a case about it?

AmulAmul