cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MantasV
New Member

Conditional formating in 'Send an email (V2)

Hello, 

 

I'm sorry if the answer has been listed somewhere, I really did try to look for it and couldn't find anything.

 

I have created a flow for quality checks where when I get a response from a Microsoft form, the responses go to a table in excel, in excel I've set up a formula to calculate a total result of the responses and all that data is then sent to the person who the quality check was done for.\

MantasV_0-1699529891289.png

What I need help with is, with conditional formatting for different types of responses, so first one would be the final result of it I want to be colored red if it's under 75, yellow if it's between 75 and 90 and green if it's above 90. I tried googling different codes to enter, but the result font seems to constantly turn out black regardless of what I do. 

And then kind of on the same page, I want to add conditions that if responses positive they would appear at one part of the e-mail and if responses were negative, they would appear at a different part of the e-mail. 

The e-mail is currently looking something like this:

MantasV_1-1699530389437.png

 

 

Any help would be greatly appreciated as I'm a little concerned that trying to enter codes into the e-mail is potentially a wrong approach all together. 

5 REPLIES 5

Here's some conditional HTML formatting:

First, create a variable to contain the result value. For illustration purposes, I have it in an Initialize variable action. I've named it MyNumber but you can name it whatever you want. Make the variable type Integer (unless there's a chance the value will ever have decimal points, in which case call it a Float. You will notice I have manually plugged in the value of 95 but this value should come from your code.

annetoal_0-1699548361536.png

Close-up:

annetoal_1-1699548717269.png

The next step is for purposes of illustration, to show you how to make a HTML string from the value. I am using an Initialize variable action to set value of a string called HTML.

Then, use this expression to generate the HTML you can insert into the Send an Email (v2) action.

 

if(less(variables('MyNumber'), 75),
    concat('<span style="color: red;">', string(variables('MyNumber')), '</span>'),
    if(and(greater(variables('MyNumber'), 75), lessOrEquals(variables('MyNumber'), 90)),
        concat('<span style="color: yellow;">', string(variables('MyNumber')), '</span>'),
        concat('<span style="color: green;">', string(variables('MyNumber')), '</span>')
    )
)

 

Now you can take the output of the HTML string variable and insert it into your HTML email:

annetoal_2-1699548825492.png

In this example, it sent an email consisting of a green number 95.

 

Hope this helps,

Anne

 

Anchov
Multi Super User
Multi Super User

You can construct Power Automate expressions for color formatting using HTML. Here are some steps you can follow, though you'll need to modify them to suit your specific situation:

1. I created a new manual flow that accepts a number:

Anchov_0-1699548891751.png

2. I create a compose Statement, that generates html according to your color formatting criteria:

Anchov_1-1699548941564.png

The expression I used to generate the correct color based on the number is:

 

concat('<span style="color:', if(less(triggerBody()?['number'], 75), 'red', if(lessOrEquals(triggerBody()?['number'] , 90), 'yellow', 'green')), ';">', string(triggerBody()?['number']), '</span>')

 

3. I send and email with the results:

Anchov_2-1699549015529.png

Email is generated showing the color formatted value:

Anchov_3-1699549115247.png

 

The same concept can be applied for formatting your email for positive or negative. 


If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers!
Rick Hurt

MantasV
New Member

Thank you both for your replies, I tried doing both of the methods, but I imagine I'm doing something wrong as it still doesn't work. 

First the method with the 'Compose' function, I left the triggers and information as they were (maybe the trigger needs to be changed somehow? But I still need to get the information from the form, before the e-mail is composed) 

MantasV_0-1699948858727.png

But the resulting e-mail I get is this:

concat('', string(triggerBody()?[100]), '')

 

 

For the other method with the variables, I've entered it as advised just the first variable I used 'Float' since as you mentioned if the result may have decimal points, I should use that. 

MantasV_2-1699949242747.png

MantasV_3-1699949258379.png

But in this case the flow wouldn't run and return results like this:

The variable 'MyNumber' of type 'Float' cannot be initialized or updated with value of type 'String'. The variable 'MyNumber' only supports values of types 'Float, Integer'.

MantasV_1-1699949148427.png

I don't really understand this error as it seems to say it supports the type 'Float' but then that it can't be converted to string? 

 

 

Again thank you both for your help and any further assistance would be greatly appreciated. 

Anchov
Multi Super User
Multi Super User

Hi @MantasV ,

The issue seems to be related to the expressions not being entered as formulas in the dynamic formula editor. Currently, they are being interpreted as plain text. Expressions enable you to add conditional logic to your actions and need to be processed by the Power Automate engine.

If you are new to expressions, I recommend watching this tutorial: Power Automate Expressions Tutorial.

 

But a short how-to:

To do this, you need to enter them into the dynamic formula editor by:
1. Click within the compose action, then click on the "Fx" button:

Anchov_1-1699969434975.png

2. Ensure you are in the "Expression" tab, and input your formula. Note that only expressions can be added here.

Anchov_2-1699969563009.png

3. If you need to add dynamic values (e.g., variables, outputs from other actions, etc.), use the dynamic values button.

Anchov_3-1699969756058.png

4. Click "Save" to insert the expression. It's crucial to note that the syntax must be precisely correct for the expression to save.

5. Verify that the expression was entered correctly and placed where you intended it within the Compose action . Expressions are denoted by the "Fx" box. The rest of the text in the Compose will be interpreted as static HTML (in this case).

Anchov_4-1699969904139.png
Please Note: You could format the HTML directly in the email action (in the body). However, I recommend using a compose action (variables work too) because the email action tends to attempt to "fix" the HTML by adding unnecessary characters, potentially disrupting your carefully formatted HTML. Make sure your HTML is accurate in the compose statement.



 

 

 

You need to turn the variable MyNumber into a string. Use this expression in place of where you have MyNumber in the email:

string(variables('MyNumber')

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,044)