I want to pass a Map<String, List<String>> from apex controller to javascript.

Here is my approach, I am using javascript remoting for it but it's not working.

controller function

global static Map<String, List<String>> getExceptions(){
    System.debug('---------------exceptions----------->' + ELC_OS_Portal_SimpleForm_Controller.picklistExceptionMap);
    return ELC_OS_Portal_SimpleForm_Controller.picklistExceptionMap;

Here I am populating static variable picklistExceptionMap in a non static method and then calling that method in constructor.

Then I am using calling this method in visualforce page

<script type="text/javascript">
        function removeExceptionValues() {
                    function(result, event){
                        if (event.status) {
                            for (var key in result) {
                                if (result.hasOwnProperty(key)) {
                                    for(var i=0; i<result[key].length; i++){
                                        $("." + key).find('option:contains(' + result[key][i] + ')').remove();
                        } else if (event.type === 'exception'){}
                    {escape: true}

Finally calling this javascript method at the end of the page


Problem is when I debug it in non static method I am able to get the value but is shows as null in @RemoteAction method.

Where am I wrong? If it's not the correct way please suggest a better approach.

  • can you post ELC_OS_Portal_SimpleForm_Controller controller code ?
    – Arabinda
    Apr 2, 2019 at 2:57

1 Answer 1


I didn't find any way to pass Map> from controller to JavaScript. I solved this issue by creating a String out of List where values of the list are separated by ; then I passed Map. In JavaScript I used split method to create a list out of value string.

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.