I am using Microsoft forms for collecting pass/fail conditions for an audit. All answers are either Pass or Fail. Is there a way I can compare every all answer to the fail condition to send an email, or do I need to add a condition for every question?
I would also like to send part of the form to a printer when it fails to alert of what the failure was. Would that be possible?
Thank you,
Hi @eric142,
Here is the example of the flow (the other one was the result when it ran).
From
xpath(xml(json(concat('{"Responses":', string(outputs('Get_response_details')?['body']), '}'))), '//Responses/*[text() = "Pass"]')
Map
substring(base64ToString(item()['$content']), 1, sub(indexOf(base64ToString(item()['$content']), '>'), 1))
Hi, @Marco
In the Map input it is asking for a valid json. I can't see the flow you attached even when zoomed in it is unreadable to me.
Thank you,
Eric
Hi @eric142, here is a solution for you.
After you trigger starts, pull the results by using the 'Get response details' action. Then use a Select (Data Operation).
Use the 'Switch Map to text mode' button to go into text mode.
In the 'From' input, we will convert the result JSON to XML to use it for XPath (thanks to Expiscornovus in another post). Use the string below:
xpath(xml(json(concat('{"Responses":', string(outputs('Get_response_details')?['body']), '}'))), '//Responses/*[text() = "Pass"]')
You notice at the end of the string "Pass". This is the text from the answers in the form we're searching for. This can also be "Fail" or something else if you want to filter on other words.
In the 'Map' input, you use the string below:
substring(base64ToString(item()['$content']), 1, sub(indexOf(base64ToString(item()['$content']), '>'), 1))
The output from the XPath is going to be a base64 unreadable string. This substring will extract the text in the XML node, in this case, the Question IDs. With this array, you can continue your flow, e.g., creating an email.
If you want to get the corresponding question; use the string below and replace
outputs('Get_response_details')?['body/re9f2aefb65084fa090ff2e00da734853']
Example of my flow when it ran.
I hope this solution is going to work for you. If so, mark this as Solved.
Thank you.
Here is a snapshot of the flow, all the questions are either PASS or FAIL. Because I have over 60 questions I wanted to know if there was a choice in the "if then condition" that would look at all the results from the questions or do I need to add every question into the flow?
Do you have an example of your form? It sounds simple, but an example helps understanding the question.
Does your printer has an email address? With my printer I send an email to the printer and this is being printed. That can work for you too.