cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
grovercorner2
Advocate I
Advocate I

Forms - save each answer in a new database row

I would like to save answers from Forms in a database in the most dynamic way possible. If my users add a new question in a form, I do not want to adjust the Flow for the new question in the old form. This way I can save multiple forms of different length to the same database. This will make is much easier to manipulate in Power BI.

 

Answers Database Columns:

  1. ID (unique ID of the submission)
  2. Question ID
  3. Answer

One form submission will have as many rows as there are questions in the form. I will probably have 2 other tables to save question text and individual response submitter names and data. TBD

 

Is this possible with flow? The "get response details" action has all the answer in the 'body' part of the json, but I can't manipulate the 'response' data from that action like I can with a normal webhook. I was thinking a loop to go through all the 'body' part of the JSON. Any other ideas?

4 REPLIES 4
RobElliott
Super User
Super User

Hi @grovercorner2 , I don't think what you want to do can be achieved. Forms questions can't live outside Forms and then dynamically populate the form, so if your user adds a new question you will need to adjust the Flow.

Rob
Los Gallardos
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.

@RobElliott , no, I would still use Forms to create and edit the forms. This question is related to how the data coming out of Forms is saved in a database. I updated the initial post as my wording was not clear, sorry about that.


I have done something similar with Survey Monkey, using the webhook action and the API to get the raw answers, parsing the json. I haven’t figured out how to do something similar with Forms as the available action are quite restrictive.

Hi @grovercorner2 

 

Please see the flow screenshot below:F3.png

 

Here, I am getting the response of the flow and extracting the attributes and the responses into an array and then running an apply to each on that array to extract individual responses and insert a new row in SQL for each of those. 

 

Expressions:

Compose 3:

split(replace(replace(string(body('Get_response_details')),'{',''),'}',''),',')

Append to array variable:

concat(first(split(items('Apply_to_each_2'),':')),substring(string(items('Apply_to_each_2')),indexOf(string(items('Apply_to_each_2')),':'),sub(length(string(items('Apply_to_each_2'))),indexOf(string(items('Apply_to_each_2')),':'))))

 

Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Thank you, this works. I didn't know I could still access the raw body of an action if it wasn't available in the dynamic. 

 

The last steps:

1. What is the formula to save grab each item of the array in the last 'Apply to each 3'

2. The question from Forms doesn't show up as text, but as some kind of key. Is there a way I can lookup each key.

 

For example: 

"r0ed3d62cbb12319b9c4a62b46ff486ad":"AnswerText"

 

How do I lookup the question from forms? That information doesn't seem to come back in the "Get Response details", but Flow somehow magically knows what each question is. 

 

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

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

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Users online (15,556)