web
Youโ€™re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id : E0XSMA5jgmENudupvixQN6
Power Automate - Building Flows
Answered

HTML Styling Text Red with Yellow Background Color

Like (0) ShareShare
ReportReport
Posted on 9 Apr 2023 12:29:02 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!

I have the same question (0)
  • Nived_Nambiar Profile Picture
    18,014 Super User 2025 Season 2 on 09 Apr 2023 at 17:37:46
    Re: HTML Styling Text Red with Yellow Background Color

    Hi @Fsomers68 

     

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

     

     

  • Verified answer
    Fsomers68 Profile Picture
    94 on 09 Apr 2023 at 14:42:01
    Re: HTML Styling Text Red with Yellow Background Color

    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

     

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

Responsible AI policies

As AI tools become more common, weโ€™re introducing a Responsible AI Useโ€ฆ

MS.Ragavendar โ€“ Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our Septemberโ€ฆ

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 736 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 396 Moderator

#3
Power Apps 1919 Profile Picture

Power Apps 1919 339

Last 30 days Overall leaderboard