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 / HTML Styling Text Red ...
Power Automate
Answered

HTML Styling Text Red with Yellow Background Color

(0) ShareShare
ReportReport
Posted on by 94

Hi all, 

 

Thanks to @Nived_Nambiar  and @v-xiaochen-msft I was able to fix my issue to have past due 'due dates' highlight red in my HTML table that I send via Power Automate each day.  Thank you again! 

 

I've identified an additional requirement based on our workflow in that we would also like to have the due date cell highlight yellow (keeping text red) if the due date is more than 5 days past due.  I've tried dropping some background-color expressions in my Select action, but am getting errors. 

Fsomers68_0-1681042357215.png

 

My current if expression is: 

 

if(less(item()?['DueDate'],utcnow()),'red','black')

 

 

My convertFromUtc expression is: 

convertFromUtc(item()?['DueDate'],'Eastern Standard Time', 'h:mm tt dddd MMMM d, yyyy')

 Then I do a Replace expression in the body of the email: 

replace(replace(replace(body('Create_HTML_table2'),'&lt;','<'),'&gt;','>'),'&quot;','"')

Which generates: 

Fsomers68_1-1681043184443.png

 

The dropping of background-color in that I've tried has not worked.

 

I'm not sure how to combine both the red font and yellow background desire in the Requestor Due Date box in my select action. Can anyone assist? 

 

Thanks in advance!

Categories:
I have the same question (0)
  • Verified answer
    Fsomers68 Profile Picture
    94 on at

    Ok - ChatGPT came through (after 6 failed tries 😉

     

    If you're looking to do something similar - this is what worked: 

    Fsomers68_0-1681050985696.png

     

    The full code is: 

     

    <div style="background-color:@{if(and(less(item()?['DueDate'], utcnow()), greaterOrEquals(div(sub(ticks(utcnow()), ticks(item()?['DueDate'])), 864000000000), 5)), 'yellow', 'white')}; color:@{if(less(item()?['DueDate'], utcnow()), 'FireBrick', 'black')}">@{convertFromUtc(item()?['DueDate'],'Eastern Standard Time', 'h:mm tt dddd MMMM d, yyyy')}</div>

     

    The first if expression is (this is what highlights yellow anything older than 5 days, using the 864000000000 ticks divided by 5 : 

     

    if(and(less(item()?['DueDate'], utcnow()), greaterOrEquals(div(sub(ticks(utcnow()), ticks(item()?['DueDate'])), 864000000000), 5)), 'yellow', 'white')

     

    The if expression for color is (using FireBrick instead of red for 508 compliance when it is highlighted in yellow it yields a warning): 

     

    if(less(item()?['DueDate'], utcnow()), 'FireBrick', 'black')

     

    The convertFromUtc expression (unchanged) is: 

     

    convertFromUtc(item()?['DueDate'],'Eastern Standard Time', 'h:mm tt dddd MMMM d, yyyy')

     

    That will yield this: 

    Fsomers68_1-1681051311059.png

     

  • Nived_Nambiar Profile Picture
    18,129 Super User 2025 Season 2 on at

    Hi @Fsomers68 

     

    Glad to know issue is resolved, for comparision of dates it is better to go via difference between dates.

     

     

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 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard