Using Microsoft Forms Likert questions in Flow

The Likert question type is a great option in Forms, which gives users a matrix of sorts, to provide a valuable answer. Check out this example I use for our user group’s feedback survey:

microsoft forms likert field.jpg

Some fun facts about the Likert scale on Wikipedia.

Using Microsoft Flow, I’d like to perform some automation when this survey is filled out. I want to send a nice, clean email off to the user group organizers sharing when a new result is submitted. Unfortunately, it’s not now that easy.

Using Likert in Flow is SO MUCH EASIER NOW!

Big thanks to Zhongzhong from Microsoft Forms team for leaving a comment on my post. Microsoft has fixed this headache, now you can just pull the value from the form without any of the nasty JSON parsing.

microsoft forms flow likert

Done! That simple.

 

 

The old stuff

I am keeping the rest of this post because 1) it took me a while to write it and 2) there’s still some good stuff in here for other use cases outside of likert fields ;)

Simply putting the field in the body of the email renders a nasty result. We get the JSON result for each of the row values, like:

Topic: { “id”: 6, “order”: 1518727860286.0, “answerOrder”: 0, “displayText”: “Excellent”, “invalid”: false, “url”: null, “description”: null, “symbol”: null, “symbolColor”: null, “isCustomChoice”: false, “customProperties”: null, “key”: null, “image”: { “altText”: null, “contentType”: null, “fileIdentifier”: null, “originalFileName”: null, “resourceId”: null, “customProperties”: null, “resourceUrl”: null } }
Speaker Presentation: { “id”: 6, “order”: 1518727860286.0, “answerOrder”: 0, “displayText”: “Excellent”, “invalid”: false, “url”: null, “description”: null, “symbol”: null, “symbolColor”: null, “isCustomChoice”: false, “customProperties”: null, “key”: null, “image”: { “altText”: null, “contentType”: null, “fileIdentifier”: null, “originalFileName”: null, “resourceId”: null, “customProperties”: null, “resourceUrl”: null } }
Office 365 Updates: { “id”: 6, “order”: 1518727860286.0, “answerOrder”: 0, “displayText”: “Excellent”, “invalid”: false, “url”: null, “description”: null, “symbol”: null, “symbolColor”: null, “isCustomChoice”: false, “customProperties”: null, “key”: null, “image”: { “altText”: null, “contentType”: null, “fileIdentifier”: null, “originalFileName”: null, “resourceId”: null, “customProperties”: null, “resourceUrl”: null } }
Community Updates: { “id”: 6, “order”: 1518727860286.0, “answerOrder”: 0, “displayText”: “Excellent”, “invalid”: false, “url”: null, “description”: null, “symbol”: null, “symbolColor”: null, “isCustomChoice”: false, “customProperties”: null, “key”: null, “image”: { “altText”: null, “contentType”: null, “fileIdentifier”: null, “originalFileName”: null, “resourceId”: null, “customProperties”: null, “resourceUrl”: null } }
Venue: { “id”: 6, “order”: 1518727860286.0, “answerOrder”: 0, “displayText”: “Excellent”, “invalid”: false, “url”: null, “description”: null, “symbol”: null, “symbolColor”: null, “isCustomChoice”: false, “customProperties”: null, “key”: null, “image”: { “altText”: null, “contentType”: null, “fileIdentifier”: null, “originalFileName”: null, “resourceId”: null, “customProperties”: null, “resourceUrl”: null } }
Food: { “id”: 6, “order”: 1518727860286.0, “answerOrder”: 0, “displayText”: “Excellent”, “invalid”: false, “url”: null, “description”: null, “symbol”: null, “symbolColor”: null, “isCustomChoice”: false, “customProperties”: null, “key”: null, “image”: { “altText”: null, “contentType”: null, “fileIdentifier”: null, “originalFileName”: null, “resourceId”: null, “customProperties”: null, “resourceUrl”: null } }

Yea, not cool. So a little Binging (yes, I Bing) helped me find a post on this, but the post was a little incomplete. Let’s dive into what we need to do with this value set.

Parse the JSON

If you don’t know what that means: “parse the JSON”; that’s okay. Basically, we need to take that ugly value, with the { and the : and the }, and make it friendly and usable. We have two options to do this, and I’ll walk through both in Microsoft Flow:

  1. Using an action
  2. Using an inline expression

Which one? If you will be using the data more than once in the Flow, across actions, or using the data to create conditions in the Flow, use an action. If you are simply using the values once, say for a quick email or save to a data source, then the second option might be faster and easier and messier.

 

Using an action – Data Operations – Parse JSON

Fortunately, there’s an action for parsing JSON. After you get the Form’s response data, drop in the action Data Operations – Parse JSON.

Parse JSON action in Microsoft Flow

For the content field, select one of the likert row values. In my example above, I’d select Topic, Speaker Presentation, etc.

For the Schema, click the link below the textbox, “Use sample payload to generate schema”. In the new dialog window, paste in the JSON output. If you don’t have it, you should be able to use mine here:

{ "id": 6, "order": 1518727860286.0, "answerOrder": 0, "displayText": "Excellent", "invalid": false, "url": null, "description": null, "symbol": null, "symbolColor": null, "isCustomChoice": false, "customProperties": null, "key": null, "image": { "altText": null, "contentType": null, "fileIdentifier": null, "originalFileName": null, "resourceId": null, "customProperties": null, "resourceUrl": null } }

Click OK and it should provide a nice Schema value.

Microsoft Flow Json action to get likert value

I highly suggest naming this action appropriately like I did above. It’s a best practice and when you have multiple values to parse, this is the only way to keep track of what’s going on.

Now you can use this variable wherever you’d like. You’ll use the displayText property, as that is the display value of the row field. Unfortunately, there is no way to get the question value from the form in Flow.

Microsoft Flow Likert Displaytext

 

Using an inline expression

The above method is pretty easy, but will add a lot more actions to your flow, if you care (and you shouldn’t by the way). If you want to suck out the value quickly since you’re using it once, you can replicate the above but in a single expression.

You will find towards the end that this method is also messier, but it still works so I thought I’d share.

This can be a little tricky, so let’s go through it slowly. Basically, the end result for the expression should be:

if(empty(body('Get_response_details')?['r468c6af2b38e4ba89167953ced7aefba']),'N/A',json(body('Get_response_details')?['r468c6af2b38e4ba89167953ced7aefba'])['displayText'])

Where the body(…)[‘…’] is the likert row value, i.e. Topic. Here’s how we get there (it’s easier than it looks).

Click in the spot of your Flow where you want the value. In my example, I’m emailing the details of the survey, so I click in the body of the email:

forms flow 1.jpg

Using the fly out window on the right, that has Dynamic Content and Expression menu at the top. Start by clicking Expression (make sure you press Expression first!). In the expression box, copy and paste in this value

if(empty(X),'N/A',json(X)['displayText'])

Micosoft flow likert expression to get vlaue

This fun expression is checking if the field is empty, if so then it will show ‘N/A’. If it’s not, then write the value.

Now, go to the second X, in json(X), and delete the X. Click Dynamic Content and click on the likert row value name, in my example Topic.

Parse likert value using json expresson

Do the same for the first X, in empty(X), and delete the X, then click the same field again.

Your expression should look like my example, except for you unique strings. Click OK.

Rinse and repeat as necessary. Here’s what my email looks like now:

forms flow 2.jpg

As noted before, kinda unwieldy, all those if(..) values. I can get away with that here since the label is right next to it.

Done!

Push yourself to do the first method I mention, as it’s cleaner and easier to understand. Also, if you were to pass this Flow off to a teammate, the first method would be easier for them to understand, with less assumptions.

‘Til next time, Happy Flowin’!

12 thoughts on “Using Microsoft Forms Likert questions in Flow

Add yours

  1. Hey David, I am struggling to understand the improvement reference by Zhongzhong that removed the need to parse JSON data. Any ideas why my flow still gives the nasty results outlined here?

  2. Yes I do see each question available, but when I insert the question in my email body it is displayed as JSON data.
    At least that`s the way is working in my dev tenant. I will try the same in my customers tenant.

  3. Hi

    I came across your blog and I thought it had answered my query. Unfortunately, when I send an email with a LIKERT question (answer!) in it, I’m still getting the JSON data.

    I have followed your blog and Zhongzhong Li’s response and it still isn’t working. Is there anything special I need to do in the Form or in the body of the email, (I see you have in yours but I assume that’s just a bit of formatting?).

    Thanks for any help you can be

    David

  4. Hi David,

    This is Zhongzhong from Microsoft Forms team. This is a super great blog post about Forms and Flow.

    Just let you know we have improved “Likert” question in Flow, so you could easily reference to the answers for each statement now.

    Hope that could be helpful :) And thanks for keeping using Microsoft Forms.

    Regards,
    Zhongzhong

    1. I hope you see this. Abe Zawodni above in the comments is asking a question about this. If you’d be willing, please review and let us know!

Leave a Reply

Up ↑

Discover more from David Lozzi

Subscribe now to keep reading and get access to the full archive.

Continue reading