Categories: Microsoft Forms Pro
* IMPORTANT *
EFFECTIVE: 2020-21-07 – Microsoft announced that Forms Pro was becoming Dynamics 365 Customer Voice. While elements of this blog post may still be accurate, keep in mind that the product has change. You can review the blogs in the D635 Customer Voice category which is being added to over time.
*** NOTE: ALL INFORMATION IS ACCURATE AT DATE OF PUBLISHING ***

So far we’ve covered a lot on Microsoft Forms Pro. This post comes with some feedback and knowledge direct from a member of the Forms Pro team at Microsoft. So special thanks to Prateek Sethi for providing guidance with the steps for the Microsoft Flow, and using the parameters effectively. In this post we will look at a simple scenario where we can create one survey, but use it on multiple web pages. Then pass a parameter back through from the web page to let us know which page they were on when they completed the survey. This allows us to do something effective like create a new Lead record when a visitor expresses interest in a specific product and capture which product they are interested in. We start off with a simple survey.

Next, we want to make sure anyone with the link (or visiting the web page where it’s embedded) can complete the survey. Click on the gear icon from the top right of the survey to go to the form settings and make sure the first radio button is selected so anyone with the link can respond.

Now we need to click on the Send Survey tab, and then click the Embed option. We will keep it inline to embed the survey on a page on our website.

Before we get the embed code, we need to add in a new parameter to pass context back in to the survey and let us know which product page the survey was on. Add in a new parameter called ProductPage (or whatever parameter you wish to pass back).

Now scroll to the bottom and click on Generate code.

For more information on how to embed your survey, take a look at this blog post which covers it in more detail. The important part that needs to be reviewed to pass the parameter back is in the render survey method. Right after “surveyDiv” we need to add in the product name for this specific web page. So if it’s being added to the sales page about Product A, we add that in quotes right after the surveyDiv parameter.

<div id="surveyDiv" style="height: 800px">
<script>
	 window.addEventListener('load', function () {
            renderSurvey("surveyDiv","Product A");
        }, false);
</script>
</div>

Now we have that on the web page, we need a Microsoft Flow that will run when someone submits the survey from the website. The Microsoft Forms Pro data is created in Common Data Service. We will give the Flow a name and select the Common Data Service trigger, When a record is created. Click the Create button to move on to the next step.

Select your environment, then Survey responses in the Entity name, and the scope as Organisation.

Our first action is from the Microsoft Forms connector. There is only one, and that’s to ‘Get response details’.

We need to get the response id of the new survey response record. To do this, we need to convert the response id to an integer value. For this, we click in the Response id field in the action, then click on the Expression tab on the right, and paste in the following, then click OK.

int(triggerBody()?['msfp_sourceresponseidentifier'])

Now we need to get the parameter we added to the survey embed code that tells which page, or product the responder was on when they submitted the survey. To do this, we are going to use the Parse JSON action. In the Content field, select the Context Data from the initial trigger step of your flow.

Click on the link at the bottom of the Schema field – ‘use sample payload to generate schema’.

Past the following in to the window that opens, making sure you use the exact name of the parameter you added to the survey in Forms Pro. Where it says “Product Name” this can say anything. It will be replaced by the ACTUAL product name you added to the website.

{"EmbedContextParameters":{"ProductPage":"Product Name"}}

Once you have clicked Done, you will see the Schema formatted correctly. Each time the flow runs, it will parse the context data and the ProductPage value.

Now let’s create a new Lead record in Dynamics 365 Customer Engagement using the Common Data Service action to create a new record. We select the right environment, and set the leads entity. We are then able to use the values from the Microsoft Forms step and get the values populated by the responder in the survey on the website. How cool is that! We will use the Last Name, First Name and Email fields to add in the corresponding survey fields. For the Topic, you can add whatever makes sense for your organisation, but here we have “Product Interest – “ followed by the value from the Parse JSON step which contains the ProductPage parameter.

Once we have created the Lead, it makes sense to now link the Lead back to the original Survey Response record. So, let’s add another Common Data Service action step, and select the Survey resopnses entity again. The record identifier is the Activity id from the original Survey response trigger at the start of the Flow. It might also be a good idea to update the Subject of the survey response and include the ProductPage value from the Parse JSON step.

Scroll down and update the Regarding field using the Lead from the Create Lead step, and set the Regarding Type as leads.

We can use the name fields from the survey response to update the Respondent field, and the email to update the respondent email address just to round it out nicely.

Looking in Dynamics 365 for Customer Engagement we see the Lead record has been created with the Topic including the Product from the ProductPage parameter.

If we drill down in to the Survey response record we see that it also identifies the product, and it’s got the Lead set as the regarding record.

We can now use this survey in all product pages on a website, but by passing through the ProductPage parameter from the survey, and using it in our Flow, we will get a clear and immediate understanding of where our new Leads are coming from.

Want to just watch how to do this? Check out the video below:


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.




18 thoughts on “Using Parameters To Pass Forms Pro Survey Context

  1. Happy to see Prateek Sethi’s name in this wonderful article. He was my mentor when I was in Microsoft.

    1. Oh that’s really cool! Yes, he was a great help on this one.

  2. The trigger will fire for any survey. What expression would you add as a trigger condition to ensure that it only fires for the expected survey ?

    1. Hi Bertrand, thanks for the comment. Yes, add a Condition action after the trigger, and add msfp_sourcesurveyidentifier eq ‘YOUR SURVEY ID’. If yes, then you carry on with your FLOW. You can get the source survey identifier from CDS but doing an advanced find for surveys, and add that field to your view, then export and you can copy the id. I hope that helps!

  3. Thanks for the great article. How can one get the Context (and related survey variables) when you dont have CDS ?

    1. Hi Misul. So, you could do the following. Create a flow in Power Automate with a trigger when a new survey response is received in CDS. Then have a Compose action. For the Compose, you can add the Context Data content from the trigger step. Then go ahead and fill out your survey one time. Go to the flow, and you should see that it ran. Open up the successful run, then open the Compose step. It should have pulled the Context Data. You can then copy this and use it in any of your other flows regarding the same survey. I hope this makes sense!

    2. Thanks for the quick reply. But is it possible to do the same WITHOUT having CDS (as CDS is a premium only feature of MS Flows)?

    3. Hi Miusl, if you are using Forms Pro, it is using CDS. You would need a license for Power Apps if you wanted to then access the data in a model driven app, but you can still use the CDS connector. It’s not CDS you would be paying for, as that comes with Forms Pro. Then it would be looking at your Power Automate license if you can create flows with premium connectors. I hope that helps!

  4. Hi Megan,

    is this still working? When I go to embed Form I do get the code but there is no option to add parameters.
    It also looks a bit different compared to your screenshots and videos. Did they change something and remove the parameters?

    1. Hi Marcel, yes, it’s changed since I wrote about it last year. All of the survey variables are added in the same place (from the ellipsis on the top right of the survey). When you copy the code, those variables should be added to your code.

  5. Hi Megan,

    thanks for great videos on Forms, we are about start using Survey Forms when closing Dynamics Cases but we want to add specific information to each response like, Customer, Case ID and Product Brand f.ex…

    So is it the above way to do this that we update the response after it has been generated or is there any other way to add this information so it will be present to each response.

    It is a requirement from our end as the reports/statistics need to be able to filter on this data.

    regards
    Martin

    1. Hi Martin, take a look at this post: https://meganvwalker.com/passing-variables-through-the-forms-pro-survey-url/ – you could follow part of that to add in some hidden questions and update them using Power Automate. Just ignore the part about passing the variable via the URL, you wouldn’t need that in this case. Instead, you would pass the variables during the creation of your survey invitation on one flow, then update the questions with those values on the response that comes back through. Hope that makes sense! The variables are always present in Dynamics in the Context Data field on each Survey Response, but if you want/need these details for reporting, this would be one way to achieve it.

  6. I’ve used Variables to provide Context to my surveys, however, I don’t want to do anything quite as complicated as WorKflows

    Am I able to simply pass the Variable into the “Responses”, and therefore see the variable result (Product A, Product B, etc) in the Excel Spreadsheet ?

    1. Hi Chris, the only way you can use any variables OTHER THAN the First Name is by using Power Automate to actually pass the values through somehow. So when you create the Survey Invitation, you are populating the variable by pulling values from some kind of data source (CDS, SharePoint, Excel). Then when the responses come back through, the variables are included in the Context Data.

  7. Hi Megan, wonderful to have such a great resource dedicated to MS Forms. I’m moving away from Zoho forms and I’m trying to store the URL of the page the form is embedded into. I saw in your video/pics above there was a URL checkbox and thought that might be what I need, however that checkbox is not there anymore. Do you know if it’s possible in Forms Pro to identify the URL of the page the form is embedded in?

    Thanks, Peter

Comments are closed for this post.