Skip to main content

Notifications

Power Automate - General Discussion
Unanswered

Using condition to send email and form to printer.

(0) ShareShare
ReportReport
Posted on by 38

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, 

  • Re: Using condition to send email and form to printer.

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

     

     

    2021-09-01_13-09-23.png

  • eric142 Profile Picture
    eric142 38 on at
    Re: Using condition to send email and form to printer.

    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

  • Re: Using condition to send email and form to printer.

    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

    re9f2aefb65084fa090ff2e00da734853 with your Question IDs:

     

    outputs('Get_response_details')?['body/re9f2aefb65084fa090ff2e00da734853']

     

     

    Example of my flow when it ran.

    flow example.png

     

    I hope this solution is going to work for you. If so, mark this as Solved.

    Thank you.

  • eric142 Profile Picture
    eric142 38 on at
    Re: Using condition to send email and form to printer.

    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?

     

    FLOW.JPG

    PASS_FAIL QUESTIONS.JPG

  • Re: Using condition to send email and form to printer.

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,666

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,996

Leaderboard