0

I am using MS powerautomate, forms, excel and office scripts to get some data, do validations, make/edit tables. In my flow, I get the data from form response and put it into JSON format to use easily in a few places. In my script, I would like to use the values by their key so the code is a little clearer rather than repeating the variables everywhere or calling by number index ..

My JSON looks like this:

{
"response": [{
    "responseID": "2",
    "fullName": "Jay S",
    "seniorityNumber": "M1",
    "rStartDate": "2022-01-11",
    "rEndDate": "2022-01-14", ...etc
}]
}

In my script, I see an object that looks like this with console.log

response:Array(1)
  0: Object
    responseID:2
    fullName:Jay S... etc

I want to use/reference the values by the key in my script like:

responseIDValue = response["responseID"] / response[0]["responseID"]

Tried searching, saw some stuff using JSON.parse() but can't get it to work.. How can I get the value by key?

Thanks!

nick
  • 789
  • 1
  • 11
  • 27

1 Answers1

1

Realized that as it was the object was actually like:

response["response"][0]["responseID"]

Took the data out of the first grouping: response :[{ }]

and it works as expected.. Been a while since I tried to code stuff! haha. –

nick
  • 789
  • 1
  • 11
  • 27