I wish to access the answers in a response object by using their index.
I saw a response by @Pstork1 where he mentioned doing exactly that. I was hoping someone could describe how that is accomplished.
For reference, here is the object in question:
Thank you for your help.
Solved! Go to Solution.
I don't know of any way to get the properties of an object(JSON) converted into an array. But the properties should be in the same order each time for a particular survey form and the keys will always match to each question. I would suggest running the survey once to find out what the keys for each question are and then creating an Excel table with the questions and the corresponding key. Then you should be able to access the answers from the JSON using the keys.
The only time looping would be involved would be to process multiple responses from different people. Then you would have an array of objects like the one you listed in your first question.
Unfortunately, that's not an array, so there is no way to access those properties by a numeric index. But you can load it into a Parse Json action and access the properties directly by name.
Thank you, @Pstork1 , for your quick reply. Perhaps I should describe what I am hoping to do in better detail.
With 40-90 questions to deal with, I am hoping to have a list of those questions that exactly matches the content and order of the questions on the Forms Pro form (which I am re-creating so the JSON will have the responses in order, too).
Having established that, I am further hoping to populate emails with the questions and responses dynamically. My strat on this is to have two arrays, one that is populated from an Excel table, and one that is populated from the "Get response details" outputs.
Then, utilizing an incrementing variable, use that variable to access the index of each array to populate the email body.
arrQuestions[(variables('intIndex'))]: arrAnswers[(variables('intIndex'))] (or something to that effect)
Assuming any of this makes sense, would you mind helping me accomplish this? I believe all I need is to get the responses into an array, which escapes me.
Thank you, again; your help is greatly appreciated.
I don't know of any way to get the properties of an object(JSON) converted into an array. But the properties should be in the same order each time for a particular survey form and the keys will always match to each question. I would suggest running the survey once to find out what the keys for each question are and then creating an Excel table with the questions and the corresponding key. Then you should be able to access the answers from the JSON using the keys.
The only time looping would be involved would be to process multiple responses from different people. Then you would have an array of objects like the one you listed in your first question.
Would I be able iterate over the JSON and somehow access the answer at each iteration and append that to an array variable?
I'm not aware of any way to do that with the different properties in the object. Each property is addressed by name.
@Pstork1 ,
It took a night's sleep, but I finally woke up to the realization of what you are saying; having an array of the question codes is as good as having an array of the answers, in this case.
Thank you for your help and patience with me.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Read the latest about new experiences and capabilities in the Power Automate product blog.
User | Count |
---|---|
24 | |
20 | |
9 | |
9 | |
7 |
User | Count |
---|---|
40 | |
33 | |
26 | |
22 | |
13 |