cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lamw
New Member

New User - Looking for recommended data structure and examples

Hi,

 

I just started working with Power Automate and I was able to build out a quick prototype Flow that processes a Microsoft Form (currently with 5 questions and one optional branch) and process the results and save that to Excel as well as send an email to the user with the question/answer. Each answer to a question has a color mapping of either Red, Yellow or Green. In addition to saving the results, I'm also aggregating the total number of each color and including that detail in the email. Although I have a working solution, I'm not happy with how I've built it mainly as I'm using a ton of variables to store the various states and values, which also makes the Flow complex to follow but also manage (init variable, set variable, get variable, etc).

I wanted to see if there was any recommended workflows or guidances on how best to optimize what I was trying to do as ultimately the Form will have over 30+ questions and I don't want to have to create variables for each tracking the value, color and any other detail I may have such as the question description. Ideally, I would be able to use some data structure that as part of processing the results, I can append an object that represents each color and the associated details. This way, its not only dynamic but I could process this structure in constructing the email (that's probably a separate issue). 

Here's an example of what the email content would look like, so being able to ideally save all this data into the data structure and then dynamically generate the HTML based on the applicable questions/answer is the end goal: 

Hi User,

Total Red: 3
Total Yellow: 1
Total Green: 1

Q1. Question 1 Text
A1. Yes

Q2. Question 2 Text
A2. No

Q3. Question 3 Text
A3. 10

...


I've read various options from using Excel Table, Sharepoint Lists and Compose option and I've got some of these implemented as a way to not have to hardcode but I've found taking these objects and constructing a data structure that I can then easily reference like object.<question>.value has been a bit difficult for me to grok. I'm wondering if I'm on the right track and if folks had any examples that they can point me to. The ones I've found online seem to be very specific to a given problem (which I can see from the various searches online) and maybe I'm missing something basic but that's been my struggle so far. I could easily do what I've described in PowerShell and probably call out to Azure Function but I'm trying to keep all the logic within OOTB O365 services and so that would be my preference. 

Thanks in advance

1 ACCEPTED SOLUTION

Accepted Solutions
v-litu-msft
Community Support
Community Support

Hi @lamw,

 

You could initialize an object variable to store the Question and answer as key-value, for example:

{
  "Question 1": "dynamic content",
  "Question 2": "dynamic content",
  "Name": "dynamic content",
  "Tel": "dynamic content"
}

Screenshot 2021-03-08 113328.jpg

Then when you want to get a specified value, you could use the property name to get:

variables('AnswerList')?['Property name']

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-litu-msft
Community Support
Community Support

Hi @lamw,

 

You could initialize an object variable to store the Question and answer as key-value, for example:

{
  "Question 1": "dynamic content",
  "Question 2": "dynamic content",
  "Name": "dynamic content",
  "Tel": "dynamic content"
}

Screenshot 2021-03-08 113328.jpg

Then when you want to get a specified value, you could use the property name to get:

variables('AnswerList')?['Property name']

Best Regards,
Community Support Team _ Lin Tu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MSFTBizAppsLaunchEvent

Experience what’s next for Power Virtual Agents

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Users online (12,307)