I am getting map in helper in callback

action.setCallback(this, function(response){
            var state = response.getState();
            var wrapperRecords = response.getReturnValue();
            var wrapperMap = response.getReturnValue().retMap;

in wrapperMap I am getting values in console:

enter image description here

How can I get the length of records based on a key(for example to get length of records for my 1st key.


To access a specific key, you'd use the exact same syntax as for an array, but you use a String:

// Output length of this key's array
console.log(wrapperMap['Product Addition to Forecast'].length);

You could output all the values by doing something like this:

  key => console.log(key+' has ' +wrapperMap[key].length +' record(s).'));

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.