0
votes

I am using a picklist in visualforce page, through apex:inputField in a form. I am saving that value in custom object. And that value is being saved in object. But when I will open that record in the same form (visualforce page). When the form is being loaded that saved value was there. but when the form has been loaded, the value become null and --None-- was selected.

I tried to use javascript with alert, but it was showing that right value. I couldn't find out the issue.

I have used below code:

<apex:pageBlockSectionItem id="Menopausal_StatusItem">  
                        <apex:outputText value="Menopausal Status:" />
                        <apex:outputPanel >
                            <apex:inputField value="{!msd.AgeVal__c}" id="ageValId" label="" style="display:none;"/>
                            <apex:inputField value="{!msd.Menopausal_Status__c}" id="Menopausal_Status" required="true"/>
                        </apex:outputPanel>
                    </apex:pageBlockSectionItem>
                    <!--<script>
                        alert('{!msd.Menopausal_Status__c}');
                        alert(document.getElementById('pageId:formId:pageBlockId:pageBlockSectionId:Menopausal_StatusItem:Menopausal_Status').value);
                    </script>
                -->

This is a dependent picklist (msd.Menopausal_Status_c) and the controlling pick list is msd.AgeVal_c.

Please help me. Thanks in advance.

1
@Marcel, no. you have problem with saving record. But I have problem with saved record. I couldn't see saved value in my page. But when I queried for that object, the value was there. - Chirayu

1 Answers

1
votes

I think this has to do with the dependent pick lists. Do you have a value in AgeVal__c? If not, Menopausal_Status__c might not be correctly rendered when loading it in the Visualforce page.

You could verify this by temporarily making the controlling pick list visibility, to check its content.