*** NOTE: ALL INFORMATION IS ACCURATE AT DATE OF PUBLISHING ***
Survey variables can be used in a Forms Pro survey to personalise forms, but also to pass information back and forth from the invitation to the response. When using these variables, they can be seen in a field named ‘Context Data’ in a survey response. If you have a license for Power Apps and can create a model-driven app that’s awesome! What if you don’t, and are trying to update an Excel file or a SharePoint list? Let’s walk through the steps of extracting survey variables when you don’t have access to a model-driven Power App.
First, in our survey, we will add in all of the variables we need. For this example, we’ll send out a survey when a case is closed and add the responses to an excel file in OneDrive, so we want to pass through the Case Number, Case Title, Case Owner and the Case Owner First name. Add these in from the ellipsis (three dots) on the top right of your survey. The name and the default can be the same. The default is used when the value for your variable cannot be found.
Next, add the variables on to your survey. The variables can be added into the survey description, questions and question descriptions. You CANNOT pass variables in as answers to your questions.
For this, I will add all responses to Excel, so I need to create my spreadsheet, and include a table. Make sure you indicate that the table has headers when you create it. Upload the file to either SharePoint or OneDrive, somewhere it can be accessed online.
Now we need to move to Power Automate and create two different flows. The first one can trigger whenever you need it to. For this example, it will trigger when a case is closed in the Common Data Service (CDS). All of the actions aren’t really that important for you to see how this works, it’s the Create an invitation or Send a survey actions that are important. These are both found in the Forms Pro connector. Below we have the Create an invitation action. This step is where we will populate the variables. Pick the survey to use, then populate the Email field with the email from your Contact record linked to the case. If you are working with SharePoint, make sure you have an email address somewhere in a field on your list. then pull in the First name and Last name. The Regarding and Recipient details do not need to be populated if you are not using CDS. Instead, you can leave those blank. If you are using CDS, type out the name of the entity to link the invite too, then a comma, then use the record ID value. Add the values for each of your variables. Finally, if needed, add a step to add your invitation URL too. Check out this post if you haven’t done it before.
Now when the email is received, and the respondent clicks on the link, the survey will be populated with values where you added the survey variables.
Now we turn our attention to what happens when the response is received. First, start your flow off with a trigger from the CDS connector when a Survey response is received. You can add in a second step to get the survey the response is linked to, and then use a condition to check and make sure it’s the survey you want to take action on.
In your get response details, use the following expression in the Response id field. This converts the id to an integer, which is needed in this situation.
int(triggerBody()?['msfp_sourceresponseidentifier'])
Now, this next part is ONLY needed if you want to get the variables out of the response (the ones we passed through the invitation), and you don’t have access to CDS, which is where the data is stored. Add in a Compose step after the Get response details step.
Search for Context Data from your trigger, and add that into the inputs for the Compose step. We are adding this for a one time need only. Add this in, then go and fill out your survey with data. Come back to your flow, and you should see it has run with success. Click on the successful run to view it.
This is the part we need. Copy the value from the inputs or outputs and just paste it into Notepad for now.
Now let’s carry on and finish editing the flow. You can leave your Compose step in the flow, just in case you make more changes to your survey in the future. No harm in it being there. If you have access to CDS, open up your survey response and access the Context Data from the main form. Next, add a parse JSON step. Add the Context Data to the Content value. Then click on the generate from sample at the bottom of the action step.
Paste in the value you copied and pasted earlier. Then click Done. This will get all of the variables that you passed through from your survey invitation.
In this example, we will add the survey responses to an excel file. Search for an select the action to add a row into a table from the Excel connector. Select the location you added the file, then find the document library and the file. You should have your table available in the table field. Now we start populating the fields you added to the table. Here you can see the Parse JSON step shows all of the variables added to the survey. Start populating your fields.
The table also has cells for the survey responses that will show after the variables. So you can add those in from the get response details step.
When a new response comes in for the survey, the second flow will run. Below we can see in blue there are values from the Survey for the name, and Survey Response for the date submitted. Orange shows values that are survey variables, and green shows values that are responses to the questions.
Want to just watch how to do this? Check out the video: https://youtu.be/NbLWx7wkYkg
Check out the latest post:
Split Your Audience By Number Or Percentage In Customer Insights - Journeys
This is just 1 of 480 articles. You can browse through all of them by going to the main blog page, or navigate through different categories to find more content you are interested in. You can also subscribe and get new blog posts emailed to you directly.
This is exactly what I needed!!
Thank ou so much!!!!
You are very welcome! Hope it has helped!
I do not have a context data setting in the compose box and no matter how hard I try I can not get the variable value… What am I doing wrong?
Hi Allen, did you create the flow first, then fill out the survey to make the flow run? You need to run it once so that you can actually then get the values.
Megan, this is exactly what I need also, but I have not been able to get it to work. Two questions. 1) Am I correct that I cannot trigger on a Microsoft Form Response being created, I have to trigger on the Common Data Service record being created? 2) When I select trigger on the Common Data Service record being created and hit Create, it asks me for Environment, Entity Name and Scope. I select current for Environment. My problem is I do not have Forms Pro as a choice for Entity Name? Could that be because I am using evaluation version of Forms Pro? Thank you so much! I have watched several of your videos already. Very helpful!
Hi Cindy, thanks for your comment. You can use the Microsoft Form response created as your trigger, but then you would still need to get the CDS record as that’s what stores the Context Data with the variables. For your second question, when you are logged in to Power Automate, which environment are you logged in to? Make sure it’s the same environment where you have Forms Pro. And what if you type in Survey rather than Forms Pro? Do you see any of the entities then?
Hi, I have the same problem and I can’t seem to fix it. I’m using the trial version of both Forms Pro and Power Automate as I’m not even sure if these services are what I’m gonna be needing, so if that’s causing the problem, then I don’t know what the solution could be.
I made sure to set the environments the same on both services, yet I don’t have Forms Pro Response as an option for the Entity Name field and I can’t proceed.
Hi Nora, things have changed quite a bit since I first wrote the article. If you search for Survey Response, do you find it then? It might have Customer Voice as the prefix rather than Forms Pro now.
Hello Megan,
Your Blog and videos have been a great source of help. However for this, I am coming up short.
I can find the field ‘Context Parameters’ in the Forms Pro Survey Invites entity records. This has what I need. I just cant seem to find a way to associate the response with the invite. I have tried:
When response submitted > Get response details > Get record (trying to Get Invite using something from the Reponse details)
Yeah. So i’m lost…
Hi Russell, when you generate a Survey Invite, there is a Context Parameters field which is where any of the variables are stored. The Context Data field then stores the same information coming back in on the Survey Response. If the same values are passed through and you can get them from the response, why do you need to associate the response with the invite? If you do need that, you could always add a variable for Survey Invite ID, and when you generate the invite with Power Automate, populate that Survey Invite ID variable. Then add a look-up field on the Survey Response entity that looks to the Survey Invite entity… and populate it using the Survey Invite ID variable that you can grab fro the Context Data on the response. Hope that makes sense!
Hello,
thanks for your blog. It really helped me. But do you know, what I can do, if I want to extract more than 15 survey variables? Right now I am limited right? I dont have access to CDS so I am not sure how to solve this. Do you have any ideas? Thanks a lot!
Ni Nico. You can only add 15 variables to a survey in Forms Pro, which is why you can’t extract more than 15 variables. It’s just not possible at the moment.
Hi, is it possible to extract the survey variable in SPO list without using CDS? Since this seems to be working fine but we dont have premium license as of now.
Hi Rupali, if you are using Forms Pro, you have CDS – that is where the responses are stored, and the only place that the variables you passed from the Survey Invitation are then stored, on the Survey Response. So not sure what you mean when you say you don’t have the premium license. Forms Pro entities are in the Common Data Service, which is why I wrote this post, so you can see how to extract the survey variables, even without a Power Apps license (which gives you the ability to access the Forms Pro entities directly).
I’m using a Forms Pro trial right now, and all of the options for CDS show as “PREMIUM” and thus I can’t build the flow. I assume if I were to get an actual subscription, these options would become available? I’m needing Pro for this specific function, but can’t demonstrate that it works since all the CDS options are locked-out.
Hi Edgardo, a standalone Power Apps or Power Automate plan license is required to access all Premium, on-premises and custom connectors. So accessing this in your flows isn’t related to the Forms Pro functionality or license, and instead is related to other licenses within the Power Platform. https://unitedkingdom.flow.microsoft.com/en-us/pricing/?currency=GBP & https://docs.microsoft.com/en-us/power-platform/admin/powerapps-flow-licensing-faq#power-automate might help.
On your first Flow screenshot I can see ‘Get Contact From Case’ and ‘Get USer From Case’ I don’t have these so I am guessing they have been renamed in your screenshots. What are the original steps called so I can follow your tutorial to the letter? Thanks
Hi Steve, I would check out these two posts as they walk through those steps in detail: https://meganvwalker.com/creating-an-invitation-to-a-forms-pro-survey/ – to create a survey invitation and https://meganvwalker.com/send-forms-pro-survey-on-case-closure/ to use the send survey step. This should give you what you are looking for.