I am trying to access JS object properties in the client controller. I get undefined if I try access it by name. But I see the properties if I log the whole object. Something I am missing?

  var uploadedFiles = event.getParam("files");
    //var objectParsed = JSON.parse(uploadedFiles);
    var docId = uploadedFiles["name"];
    for (var key in uploadedFiles) {
          if (uploadedFiles.hasOwnProperty(key)) {

Console output

enter image description here

1 Answer 1


Your JSON [{"name":"xxx","documentId":"xxx"}] looks like an array, not an object.

Change the way you get the docId to

var docId = uploadedFiles[0]["name"]; or var docId = uploadedFiles[0].name;

and the loop to

for (var key in uploadedFiles[0]) {

  • Thank you! SF Documentation says the event.getParam() returns a JS object, not an array. But that worked. Thanks again!
    – Allen Mann
    Oct 31, 2017 at 20:26
  • :) You never know... it pays to be eagle eyed when checking your debug logs. I've gone through this same thing too many times to count. Oct 31, 2017 at 20:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .