web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Adding background colo...
Power Automate
Unanswered

Adding background color to HTML table cell based on condition

(0) ShareShare
ReportReport
Posted on by 52

I created a table in an email using HTML code (because it worked better than creating the table with Create HTML Table).  Here is the part of the HTML:

 

 SMiller3_0-1693836379967.png

 

that produces this result below the column headers:

 

Entry

Previous

UPDATE

Quantity

1

2

 

I need to change the background color of the Quantity UPDATE cell when the quantity changes from previous.

 

When I create the following formula in a compose and place its output right before output for the update column, it just puts the word yellow before the 2.  

 

if(outputs('Get_changes_for_an_item_or_a_file_(properties_only)')?['body/ColumnHasChanged/Quantity'],'yellow',)
 
How should the expression look to achieve desired result and where exactly should the output be placed in the HTML?
 
TYIA
Categories:
I have the same question (0)
  • ChristianAbata Profile Picture
    8,951 Most Valuable Professional on at

    hi @SMiller3  here is an example about using if as expression

    If (true/false,if true,if false)

    As you can see you need to provide first a true or false value. How can you get that? maybe using another expression like empty(). For example: If Column is empty then true, if no then false.

     

    If(empty(Column),'ShowBlackColor', ShowYellow)

     

    As you are working on HTML I'll replace the css code with my expression.

     

    so you can try if(true/false,'style='color:black'',style='color:yellow')

  • SMiller3 Profile Picture
    52 on at

    I think I have the formula with the condition, but am having trouble placing it in the html.

     

    I made a simpler expression just to get the cell to turn yellow:

     

    style=\"background-color:yellow;

     

    and put it in the html as below:

     

    SMiller3_0-1694621834120.png

    This is the result:

    SMiller3_1-1694621891119.png

    If placed right before dynamic content, I get this:

    SMiller3_2-1694621956223.png

    And when I placed the style color expression between <td and width=252, I get this:

     

    SMiller3_3-1694622175888.png

     

    Does anyone know where to put the expression so it will look like this?

    SMiller3_4-1694622304743.png

     

     

  • Verified answer
    SMiller3 Profile Picture
    52 on at

    For anyone that's interested, I was able to figure this out.

     

    Based on the original example, I created a compose action with if expression:

     

    SMiller3_0-1694713120619.png

     

    In the body of the email, I inserted the outputs from above right before <p class=MsoNormal following the <td for the relevant cell:

     

    SMiller3_1-1694713234700.png

     

    Notice (highlighted in yellow) that the space between <p and class needs to be removed and another </p> needs to be added (its initial<p is in the compose action).

     

    The result is:

    SMiller3_2-1694713547061.png

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard