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

Using variables in your Forms Pro surveys is essential when creating a personalised experience for your respondents. There are so many ways to use them to display data in both email templates and surveys, but they can also be used to determine which language to display the survey in on a person by person basis. Thanks to Henrik Kappel from Wikap for prompting me to write this one. The locale variable is relatively new, and I just hadn’t got around to writing about it yet, and he sent me an email with his findings, so this post is a combination of that and some extra stuff that might be helpful. In this post, we will use the locale variable to send a survey to a recipient using a specific template and survey language based on a field on their Contact record.

The first thing we need is the locale variable in our survey. For any new surveys created, this is added as standard, although it can be removed. If you want to add this to an older survey, just add a new variable with the name of locale. You need to set a default, so you can just add in the language code for your environment or survey default language.

Next, make sure you have your survey set up with your additional languages translated. There is a great featured which allows you to edit all of the translations via a download at once and import them back in with an Excel file. Another bonus, if you are not sure what the language codes are, you will find them in the download file.

Next, create all of your email templates in your various languages.

Now we need a way to determine the preferred language for each customer. In this example, I am using a Common Data Service (CDS) environment, which for those of you in the Dynamics world, is going to be the same thing. Add an Option Set field, and then add your languages. You will need to make a note of the value for each option. Assuming you aren’t behind the times and using the classic (a.k.a. old) way of editing things, you can get the value by clicking on the ellipsis and then view more next to each value. Copy the values, but remove the commas from them. If you are using SharePoint, you can still do this, but won’t need any value. Although it might be tempting to put the language code, many users may not know what they relate to, so sticking with the full word makes more sense.

Next we need to create a flow in Power Automate. I wrote about how to add trigger conditions to your flows here, so start off your flow with this in mind so it only runs when certain logic applies. This flow will run on the update of a case record, but only when the status code is 5, which means resolved. Your trigger can be anything, this is purely an example.

The first action will be to get the Contact linked to the Case. After that we can get the preferred language from the Contact. In order to determine which language code that should be, we will do a Compose step with an expression that will set the correct language code based on the value from the Preferred Language option set added to CDS. Below you can see the code used in this example. Review it, and then modify as needed to work for your own field name and values.

if(equals(outputs('Get_Contact')?['body/mvw_preferredlanguage'],916780001),'fr',
if(equals(outputs('Get_Contact')?['body/mvw_preferredlanguage'],916780002),'de',
if(equals(outputs('Get_Contact')?['body/mvw_preferredlanguage'],916780003),'es',
'en-gb')))

Now we are going to set the correct email template to send based on the Preferred Language on the Contact. Add in the Send a survey action from the Forms Pro connector. Fill out the fields, and select the survey. Pick one of the email templates that you want to send. Then, click on the ellipsis from the top right of this action, and click on Peek code.

Here we can see the EmailTemplateId for the template we selected. Copy just the id (the part in between the quotes) and paste it into notepad. Now go back and change the template to the next language, and walk through the steps again until you have grabbed all of the email template ids.

Now use the expression created for the language code, and replace the code with the corresponding id. So, instead of having if(equals(outputs(‘Get_Contact’)?[‘body/mvw_preferredlanguage’],916780001),’fr’, you might have if(equals(outputs(‘Get_Contact’)?[‘body/mvw_preferredlanguage’],916780001),’ade98cb4-0d53-4fc3-ba0d-abaa147acd55′ instead. Add your new expression for the email templates in to another Compose action step in the flow, above the Send a survey step.

Finally, go back to the Send a survey step, and set the two outputs into the Email template and locale values respectively.

Close a case, and the flow should run. Here we have an email template in German based on that language being selected on the Contact record.

Clicking on the link takes us to the survey, also in German. The respondent can always change the language from the dropdown at the top right of the survey if they wish, but using the locale option means it doesn’t matter what their browser language settings are, you can set the language of the survey for them.

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


Check out the latest post:
Auto Assign Leads Without Code Using Lead Scoring & Work Assignment


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