0

I am getting map in helper in callback

action.setCallback(this, function(response){
            var state = response.getState();
            var wrapperRecords = response.getReturnValue();
            console.log('wrapperRecords-->',wrapperRecords);
            var wrapperMap = response.getReturnValue().retMap;
            console.log('wrapperMap-->',wrapperMap);

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.

1

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:

Object.keys(wrapperMap).forEach(
  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.