0

I am having a custom page on opportunity which has dependent picklist where Market Place is dependent on venue

On child page I am setting values as

window.parent.opener.document.getElementById(venueId).value='{!JSENCODE(venueValue)}';

where venueId is <apex:inputField value="{!oppty.Venue__c}" required="false" id="VenueId" />

I am not able to get dependent picklist value in market place.

  • Instead of JS, can you try setting in constructor or controller method? – Amit Bangad Jul 16 '15 at 9:12
  • I did not got you how can i set value="{!oppty.Venue__c}" from another controller? – Swapnil Kale Jul 16 '15 at 9:48
  • Maybe I did not get your question right but - if you have the picklist dependent on object then you only need to show them up on visualforce page using inputfield, and it will work. – Amit Bangad Jul 16 '15 at 9:53
  • I want to set picklist value using javascript I am using window.parent.opener.document.getElementById(venueId).value='{!JSENCODE(venueValue)}'; but picklist value is not getting set. How to set input field with picklist value using javascript is my question. – Swapnil Kale Jul 16 '15 at 10:24
0

If you are having multiselect picklist, value in multiselect can be set as

<script type="text/javascript">
function setValue()
{ 
    var desiredValue = '{!JSENCODE(venueValue)}';
    var selectedItem= window.parent.opener.document.getElementById(venueId+ '_selected');

    var unselectedItem = window.parent.opener.document.getElementById(venueId + '_unselected');
        for(var i=0; i<unselectedItem.options.length; i++) {

        if ( unselectedItem.options[i].text == desiredValue ) {
            selectedItem.appendChild(unselectedItem.options[i]);
            unselectedItem.removeChild(unselectedItem.options[i]);
        }                                       
    }
}

Here one should not forget to append _selected and _unselected to get Id for multiselect picklist.

If you are having single select picklist you just have to assign value and call onchange fuction so that dependent picklist value gets populated. It can be done as <script type="text/javascript"> function setValue() { window.parent.opener.document.getElementById(venueId).value='{!JSENCODE(venueValue)}'; window.parent.opener.document.getElementById(venueId).onchange(); } </script>

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.