1

I am currently working on a wizard to allow our users to create Opportunities easier. I have the following field dependencies set up on a related object:

  1. 'Type' picklist (Controlling Field) to 'Sub Type' picklist (Dependent Field)
  2. 'Sub Type' picklist (Controlling Field) to 'Options' multi select picklist
  3. 'Type' picklist (Controlling Field as in 1) to 'Options 2' multi select picklist

Numbers 1. and 2. above is part of a multi layered dependency, while 3. is a single dependency.

When I add these fields to the wizard the dependencies work but if I click Next/Previous in my wizard then go back to the page with these fields on I lose my data from the multi select picklist 'Options'. The strange thing is that data for 'Options 2' multi select picklist is fine.

Essentially, it seems this only happens when I have a two-level dependency, where the dependent field is a multi select picklist. I've tried to replace the multi select picklist with a standard picklist and there is no loss of data. I also think the data is still set in the field (when looking from the controller) but just doesn't show up on the visualforce page.

Is this a known issue and are there any workarounds here?

UPDATE (22/04/2013):

Posted code below - this is a page I mocked up so I could easily attempt to fix the issue:

WizardPage1:

<apex:page StandardController="Custom_Object__c" extensions="WizardPageController">

    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockButtons >
            <apex:commandButton action="{!page1}" value="Previous" />
        </apex:pageBlockButtons>

        <apex:pageBlockSection >
            <apex:inputField value="{!Custom_Object__c.Type__c}" />
            <apex:inputField value="{!Custom_Object__c.Options_2__c}" />

            <apex:inputField value="{!Custom_Object__c.Sub_Type__c}" />

            <apex:inputField value="{!Custom_Object__c.Options__c}" />
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

WizardPage2:

<apex:page StandardController="Custom_Object__c" extensions="WizardPageController">

    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockButtons >
            <apex:commandButton action="{!page1}" value="Previous" />
        </apex:pageBlockButtons>

        <apex:pageBlockSection >
            <apex:outputField value="{!Custom_Object__c.Type__c}" />
            <apex:outputField value="{!Custom_Object__c.Options_2__c}" />

            <apex:outputField value="{!Custom_Object__c.Sub_Type__c}" />

            <apex:outputField value="{!Custom_Object__c.Options__c}" />
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

WizardPageController:

public with sharing class WizardPageController {

    private Custom_Object__c record;

    public WizardPageController(ApexPages.StandardController controller) {
        this.record = (Custom_Object__c) controller.getRecord();
    }

    public PageReference page2() {
        return Page.WizardPage2;
    }

    public PageReference page1() {
        return Page.WizardPage1;
    }
}

I've also realised that this issue also affects the 'Options 2' multi picklist as well. I didn't realise this before as I had forgotten to set the field dependency up for this field.

The issue seems to be the way Salesforce have handled the dependencies/multi select picklists in visualforce. The page generation appears to do the following:

  1. Load values into all fields on page
  2. Load dependencies for fields
  3. Load multi select picklist options based on dependencies

As the loading of multi select picklist options are done last, I think when the values are loaded onto the fields there are no options and therefore will not set the options as 'selected'.

  • It might be useful to post the relevant VF markup and controller code you're using. – JCD Apr 19 '13 at 17:30
  • Code posted above, although I'm not sure how useful it is – Ben Apr 22 '13 at 9:44
  • I've also added additional comments based on my investigations. – Ben Apr 22 '13 at 9:49
1

This has been accepted by Salesforce as a defect and they are currently looking into it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.