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 ***

I’ve written so much about variables in Forms Pro and what you can do with them. After a chat with Welly Lee, Head of Product for Forms Pro at Microsoft, he shared yet another way we can use variables to create personalised surveys, and pass hidden variables back through survey responses. In this post, we look at how you can share a direct link to a survey, which would typically mean no personalisation is available. However, by appending variables to the end of the survey URL, we have so many options available to us. Check this out!

For this scenario, we have an online event people are attending. There are twenty different sessions going on throughout the day. Rather than have a different survey for each session, we want to have one survey, gather all of the responses, and know which session it is that the response relates to. The first thing we need to do is set up a new variable. In this example, it’s called SessionID.

We then need to add a question to the survey which will be kept hidden. This will be used to populate the Session ID variable back in as the answer at a later stage in the process.

You can then also use the variable in the survey itself.

In order to pass the SessionID variable through into the survey, we need to append it to the end of the Survey URL. So, when clicking on Send Survey and getting the URL, we can add &ctx= and then add a variable combined with a value. Below we can see the SessionID variable used, then Forms Pro Level One passed as the value for the session. The value would then be changed for each of the sessions at the event.

https://forms.office.com/FormsPro/Pages/ResponsePage.aspx?id=sZzdL-71VU-9jqfEAukn4L4m8nL7gGRPptWJgekdXoVUMlZOMVg3SlFPQk8zNloxSEhOVzU0R1pOTC4u&ctx={"SessionID":"Forms Pro Level One"}

Multiple values can also be passed using this format and keeping the variables and values in pairs.

&ctx={"<Var1>":"<Value1> ","<Var2>":"<Value2>"}

When viewing the survey, we can see the value for the SessionID variable is displayed. This is great, and a nice way to use it on the survey, but what we really want is to get that sessionID value back into the hidden question as a response.

To pass the value back through, we need to use Power Automate and set up a flow. Our first step is a trigger from the CDS connector when a survey response is received. Be sure to set a trigger condition so it only runs on the survey you want it to. You can follow this article to see how you can achieve this. Next, add a Parse JSON step and add the Context Data value as the Content, and add the Context Data schema that can be found on a response. You will need to complete the survey once in order to get this. If you have access to CDS you can follow some steps in this blog to figure out how to get it, and if you don’t have access to CDS you can follow this blog.

Now we need to find the hidden question we added to the survey. For this, we will use the List records action from the CDS connector. Our filter query is searching for the question that has the same name as our hidden question (Session ID in this example) and also where it equals the same source survey identifier as the survey response that was received.

msfp_questiontext eq 'Session ID' and msfp_sourcesurveyidentifier eq '@{triggerOutputs()?['body/msfp_sourcesurveyidentifier']}'

Our final step of the flow is to create a new question response for the Session ID question and link it back to the survey response we received. We need to fill out the following fields. The SessionID from the Parse JSON step will go into the Name, Key phrases and Response fields. The Source response identifier and the Source survey identifier will be pulled from the values from the initial trigger step. We can set the Owner as the same Owner of the survey response (making sure to set the Owner Type), and the Survey Response must be the Activity id from the initial trigger step. There are two expressions needed. First, one for the Source question identifier. This gets the source question identifier from the question pulled back in the previous List records step:

@{first(body('List_records')?['value'])['msfp_sourcequestionidentifier']}

Then, for the Question field, we use this expression. This gets the question id from the question pulled back in the previous List records step.

@{first(body('List_records')?['value'])['msfp_questionid']}

Now if we go to Forms Pro and look at the responses, we can Export all of them to Excel (or we could view in CDS if desired).

The Session ID field has been populated so we can see exactly which session the feedback has been provided for. 🙂

Want to just watch how to do this? Check out the video: https://youtu.be/7RPMGjaP1EU


Check out the latest post:
Access To Manage Consent From Lead And Contact Records


This is just 1 of 443 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.




25 thoughts on “Passing Variables Through The Forms Pro Survey URL

  1. This really helps! Thank you for the great post.
    One question, if I pass more than one variable, can I insert all of them to response database with one flow, or I have to create flow for each variable?

    1. Hi Archates, you can do it all in one flow, just do a series of action steps to do this multiple times.

  2. Hi Megan,
    I am trying to implement this post. If I use a URL to my form with &ctx={} appended, the form is displayed using the default value for my variable. If I use the URL with &ctx={“ClassName”:”Learn”} appended, I get a “Sorry, something went wrong” error. If I do a “Send Survey” from within a flow, I am able to initialize ClassName successfully, but I would love to be able to do it this way. Do you have any suggestions? THANKS!

    1. Hi Cindy, not sure if it’s just the way that was pasted into the comment, but the quotes around ClassName look a little strange? Could that be it perhaps? Feel free to email me using my contact form and share the survey link and I can take a look for you.

    2. Megan, thank you for replying. After playing with this a bit more, I was able to get it to work. I am not sure what I was doing wrong. Now I am going to try to create a QR code using my URL with the variable appended onto the end. Is that possible within Forms Pro, or will I have to use some other QR code generator, do you know?
      Thanks so much!
      Cindy

    3. Awesome, glad you got it working Cindy! Correct, you will need to use a QR Code Generator for that. There are plenty out there, but here is one for you: https://www.qr-code-generator.com/ – the QR Code within Forms Pro will only contain the basic Survey URL, and not any of your variable parameters.

  3. I have this working the way that I want. It’s pretty great! Thanks for your help.
    Cindy

  4. Hi Megan! We met with Welly Lee a few weeks ago – I told him your website has been a HUGE help getting me started. Hope he told you.

    I implemented a form and flow that use the technique you describe above. Works great! Lets us have one form and one flow but use them for multiple projects, whereas we had been hardcoding project information into the form and into the flow and replicating for each project.

    I am having a weird problem though, and although it has nothing to do with forms, I am hoping you have run into it.

    I am appending two variables to my URL like this:
    &ctx={“ProjectID”:”10000”,”ProjectName”:”ProjectTest”}
    In the browser it gets encoded to look like this:
    &ctx=%7b%22ProjectID%22:%2212345%22,%22ProjectName%22:%22TEST%22%7d

    Works fine.
    But something is happening as we email the URL or copy and paste to new locations, that is causing it to sometimes encode like this:
    &ctx=%7b%E2%80%9CProjectID%E2%80%9D:%E2%80%9D12345%E2%80%9D,%E2%80%9DProjectName%E2%80%9D:%E2%80%9DTEST%E2%80%9D%7d
    So instead of encoding the quotation marks as %22, we end up with %E2%80%9D. This link does not work, displays “loading” indefinitely.

    The URL’s look identical, and the links that the URLs point to (in the tooltip box) are identical. It’s only after the encoding that we see the additional characters somehow getting introduced.

    I know it’s weird. We’re probably doing something wrong, but sure don’t know what. Have you seen anything like this before?

    Thanks so much!
    Cindy

    1. Hi Cindy, that’s so nice of you to tell Welly that! Lovely man, it’s great getting to work with him.

      So I think you are going to need to make sure you share your URL with the Survey Link then your appended variables (&ctx={“ProjectID”:”10000”,”ProjectName”:”ProjectTest”}) right after it, and maybe save that somewhere. Or use Power Automate to generate the full link and pass the variable extra strings to the end of it. There is something specific called URL encoding which converts characters into a format that can be transmitted over the Internet. %22 is the quote, and %7b is the curly bracket. UTF-8 encoding uses e2 80 9c for a left quote and e2 80 9d for a right quote. So when you copy that link when it resolved itself in the browser, and you paste it into something like an email or other location, it’s changing from the URL encoding to UTF-8 encoding.

      So stick to just saving the URL you create by appending the variables, and NOT saving one that you copy from the browser once you have opened up the survey using the link you created. If that makes any sense? 🤔

  5. Yes, it helps to know that what we are seeing is UTF-8 encoding. We are not ever trying to use a URL from the browser. We start with the URL generated in Forms and then type in our variables. But somehow, in the process of emailing the URL, or editing it for different projects, the UTF encoding is getting in. Now that we know what it is, we can pay more attention where it might be happening. Thank you so much!

  6. Hi Megan, we are trying to use this on the new Dynamics Customer Voice, it should have stayed the same.

    I add the ctx and the variables but when I try to check the results they are not registered.

    Have you ever tried this on Dynamics Customer Voice? Please help

    1. Hi German. No, I haven’t tried it again since the upgraded, but you are right, it should still work. What exactly isn’t registering? Where are you looking for the results? Have you created your flow in Power Automate? Does that run successfully?

  7. Hi Megan,

    It seems like the responses have a delay of one day or so for the detailed download option.

    When I say the information isn’t registering, I’m talking about the parameters that I’m trying to pass through the URL, because I can see the new response on the dashboard, but it says that there are no answers to the hidden questions I’ve added to pass the parameters.

    I downloaded the detailed responses and it did add the parameters in some cases, but not directly to the fields related. It populated the context data to a new field called Personalized Data.

    This is the URL I’m using
    https://customervoice.microsoft.com/Pages/ResponsePage.aspx?id=MedvpQziekSCVOFpbHywCeUq8gqLl-BDvVZyryKEs_pUN0dNRzdSSUNVU1hZUjk3NlY5S1hRSE1WMi4u&ctx={“IDPDV”:”EDS0001″}

    Thanks for the help! 🙂

    1. Hi German. It’s possible that things have changed with Customer Voice. I would need to test this out. I will try to do that over the weekend if I have time!

  8. Hi Megan,
    Thanks for great post. I am looking for something similar. Maybe, I am a bit new to this. Can you do something similar if you want to send one survey to customer combining several forms with different questions? Of course, somehow you need to know which forms to add. The scenario would be after a customer delivery and you want to customize a survey based on features installed. Each feature represent one form with different questions/tests.

    Br Jørgen

    1. Hi Jørgen, I think you would find it challenging to pass variables through the URL with several forms. You could use branching rules on one form and decide which questions to show or hide based on the variables you have passed through the URL. So using one form, yes I think you could achieve that, but not trying to do several forms at one time.

  9. Hi Megan,

    Thanks for the this great post. I had created flow which successfully post my variables values to respective entities. I was able to get all information including my variables values until I was on Forms Pro. As forms pro is migrated to Dynamics 365 Customer voice portal, I am facing trouble in getting data into exports. I checked my flow, it’s running as usual and setting data into places. When I try to export it for analysis I am not able to view values of the variables in respective columns. The last column(“FormsProData”) in export file have all the values of variable but I need they should be into their respective attributes. I really appreciate you for this article.

  10. Hi Megan,
    I’m also struggling getting this to work in Customer Voice, would really appreciate if you could test it again and validate if we are missing something or if this is no longer possible.

    1. Hi Timo. I would love to if I have the time! Just not possible right now with my current regular workload. Hopefully, in the future, I will have time!

  11. Great stuff! Thank you for sharing.

    One question though. How do you know the variable name for “Session ID” becomes “SessionID”?

    In my case the field is titled something longer like “Please enter in your ID number.” Would that become “PleaseenterinyourIDnumber” as a variable name?

    1. Hi Drew. You can call your variables in Customer Voice whatever you would like, but they cannot have spaces in them. So I would suggest you name your variable as just ID or IDNumber or something simple.

  12. Any update on whether or not you can pass URL variables in Customer Voice? It doesn’t appear to work for me.

    1. Hi Gino, pass them where, in what way, and for what purpose?

Comments are closed for this post.