Forum Discussion

Haniel Croitoru's avatar
Haniel Croitoru
Learn Expert
Mar 15, 2018

Parsing Microsoft Forms Likert questions using Flow

Earlier this year, Microsoft announced the Likert survey question type in Microsoft Forms.  A Likert captures multiple choice question on a scale.  

 

When the survey responses are loaded into a Flow, each of the Likert options is stored in a separate dynamic content value as shown below:

 

 

 

Looks simple, but there's a catch.  Each of the values is actually captured as a JSON object rather than the simple response.  To get to the actual value, I had to leverage the Parse JSON action to convert the value into properly structured JSON.  The format of JSON payload is as follows:

 

{
  "id": 5,
  "order": 1.0,
  "answerOrder": 0,
  "displayText": "Orange Juice",
  "invalid": false,
  "url": null,
  "description": null,
  "symbol": null,
  "symbolColor": null,
  "isCustomChoice": false,
  "customProperties": "{\"IsGenerated\":true}",
  "key": null,
  "image": {
    "altText": null,
    "contentType": null,
    "fileIdentifier": null,
    "originalFileName": null,
    "resourceId": null,
    "customProperties": null,
    "resourceUrl": null
  }
}

 

Then, to access each of the values, I leverage an expression for the Parse JSON actions.  For example, to get the breakfast drink, I used the expression below

 

body('Parse_Breakfast')['displayText']

Here's what my flow looks like to parse out the Breakfast, Lunch, and Dinner drink responses:

 

 

Hope you find this trick useful.

  • Mohamed Mahboob's avatar
    Mohamed Mahboob
    Copper Contributor

    I did not you clearly, I need to extract the value of Likert from the mircosoft form while forwarding the notification using Microsoft flow.

     

    I did not get you in the later part. Please explain me in brief

    • Haniel Croitoru's avatar
      Haniel Croitoru
      Learn Expert

      Sorry for not clarifying in my original post.  The Parse_Breakfast is the JSON output for the Breakfast value using the following schema:

       

      {
          "type": "object",
          "properties": {
              "id": {
                  "type": "number"
              },
              "order": {
                  "type": "number"
              },
              "answerOrder": {
                  "type": "number"
              },
              "displayText": {
                  "type": "string"
              },
              "invalid": {
                  "type": "boolean"
              },
              "url": {},
              "description": {},
              "symbol": {},
              "symbolColor": {},
              "isCustomChoice": {
                  "type": "boolean"
              },
              "customProperties": {
                  "type": "string"
              },
              "key": {},
              "image": {
                  "type": "object",
                  "properties": {
                      "altText": {},
                      "contentType": {},
                      "fileIdentifier": {},
                      "originalFileName": {},
                      "resourceId": {},
                      "customProperties": {},
                      "resourceUrl": {}
                  }
              }
          }
      }

      Here's what the Flow looks like

       

       

       

      • Gregory Sharrow's avatar
        Gregory Sharrow
        Copper Contributor

        Great blog, how would you do something similar with a multi answer question in forms?  Right now it comes in as one string (csv) that contains all the answers that were checked.  I need to split those out and treat them as separate objects.

    • null ymichea's avatar
      null ymichea
      Copper Contributor

      ... just in case someone else is looking for this... for the schema, you just need to select "Use sample payload to generate schema", and copy and paste from the JSON output you may have (similar to the example included in the post). 

      For the "Content" field you should use the corresponding field from the form

Resources