cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SylvainCorney
Frequent Visitor

Get response details -> append to file only the responses that are not "NULL"

Hello all,

 

I have a Form with about 30 questions (Microsoft Forms), in the 30, not all are mandatory.

So far I have collected them individually with " Get Response details" and "create a file", a HTML file that has all the questions and answers displayed in any Browser.

 

What I am looking for is to do pretty much the same, but exclude all the questions and answers "null" that were not answered, and generate a HTML file from this.

This is my flow so far.

SylvainCorney_0-1604931226198.png

 

I tried to get the results with a condition to append in 1 html file only the questions that are not equal to "NULL", but it did not work.

 

Looking for suggestions and directions.

 

Thanks,

Sylvain

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User III
Super User III

Hi @SylvainCorney 

 

Follow the below steps:

 

1. Add a string type variable

2. Declare a compose and map the output

3. Add an IF condition to check the compose output length greater than zero

4. Under the true statement set the variable with HTML tag and related dynamic property

5. Under the false statement set the variable with HTML tag you want

6. Under the Create file step map the variable

 

Do the same steps for all the IF conditions.

 

Another way you could do is add all the IF conditions as an expression under Create File but this could be a long complicated expression.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

4 REPLIES 4
abm
Super User III
Super User III

Hi @SylvainCorney 

 

Under the file content you are mapping the dynamic values from Microsoft Forms. So you could use an IF expression to output the values.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

Hi abm,


I like the idea and did some research on it, but never been able to find a good example to try it out.


The existing code is per below:


Question 1 result is required

<tr><td>Confirmed sites ?</td><td>@{outputs('Get_response_details')?['body/AnswerfromQ1']}</td>


Question 2 result depends on the customer, so it could be blank and if blank/empty/Null, to not add to the HTML report, in the case is not empty need to be added to the HTML file

<td>Assumption(s) ? Provide the list.</td><td>@{outputs('Get_response_details')?['body/AnswerFromQ2']}</td>


Question 3 result depends on the customer, so it could be blank and if blank/empty/Null, to not add to the HTML report, in the case is not empty need to be added to the HTML file

<td>Confirm Routes & Sites - Provide the list.</td><td> @{outputs('Get_response_details')?['body/AnswerFromQ3']} </td></tr>


Question 4 result depends on the customer, so it could be blank and if blank/empty/Null, to not add to the HTML report, in the case is not empty need to be added to the HTML file

<tr><td>Opportunity number ?</td><td>@{outputs('Get_response_details')?['body/AnswerFromQ4']} </td></tr>

 

Now how do I add IF statement, or IF then or else... ?


Q1 Stays as is

If @{outputs('Get_response_details')?['body/AnswerFromQ2']} not equal to NULL, then append to html file, if @{outputs('Get_response_details')?['body/AnswerFromQ2']} equal to NULL, skip to Q3.

If @{outputs('Get_response_details')?['body/AnswerFromQ3']} not equal to NULL, then append to html file, if @{outputs('Get_response_details')?['body/AnswerFromQ3']} equal to NULL, skip to Q4.

etc...


The above is just the idea, but from a code point of view, I am at lost.

Sorry for the newbies question, I am new new to this, but love the concept..


Thanks for your support.

Sylvain

Hi @abm 

 

I put something together using IF Statement, but it is not working as expected.

 

<tr role="row" class="even">
    <td class="">Confirmed sites & survey results</td>
    <td>@{outputs('Get_response_details')?['body/raa010148835a4dd3845ee41f25456639']}</td>
         if (@{outputs('Get_response_details')?['body/r4f199078c71745b79eb07e027e9bb973']}!= null)>{
            <td>Item considered as an assumption(s) ? Provide the list.</td>
            <td>@{outputs('Get_response_details')?['body/r4f199078c71745b79eb07e027e9bb973']}</td> }
        else {
            <td></td>
            <td></td> }

        if (@{outputs('Get_response_details')?['body/r9bdab50111694ce9b317eaf5a2fd26d8']}!= null) {
            <td>Confirm Routes & Sites - Provide the list.</td>
            <td>@{outputs('Get_response_details')?['body/r9bdab50111694ce9b317eaf5a2fd26d8']}</td> }
        else {
            <td></td>
            <td></td> }

</tr>

 

I tried in adding <script> in between <td> but it mess up the page layout and remove my Buttons to export to Excel or PDF.

 

the @{outputs('Get_response_details')?['body/r9bdab50111694ce9b317eaf5a2fd26d8']} is variable from a Forms that users have answered questions.

 

Not sure if I provided enough code to see where is the issue.

 

Thanks,

Sylvain

abm
Super User III
Super User III

Hi @SylvainCorney 

 

Follow the below steps:

 

1. Add a string type variable

2. Declare a compose and map the output

3. Add an IF condition to check the compose output length greater than zero

4. Under the true statement set the variable with HTML tag and related dynamic property

5. Under the false statement set the variable with HTML tag you want

6. Under the Create file step map the variable

 

Do the same steps for all the IF conditions.

 

Another way you could do is add all the IF conditions as an expression under Create File but this could be a long complicated expression.

 

Thanks



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blogPower Automate Video Tutorials

View solution in original post

Helpful resources

Announcements
MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Top Kudoed Authors
Users online (71,809)