Skip to main content

Notifications

Power Automate - Building Flows
Unanswered

Trying to format cells in an HTML table based on status value and using substitute to separate names in a string

Posted on by 353

I have the following Flow that runs a report of Field trips from Sharepoint lists and then emails an HTML table (see Flow-overview.PNG)

 

I am then trying to do 2 things which are not working:

I'm trying to use substitute to separate out people's names from a long string that looks like this: 

Joe Louis ; WARREN SMITH; Timothy Idesfelt ; Thomas Jones; * *

 

I would like it to look like: Joe Louis, WARREN SMITH, Timothy Idesfelt, Thomas Jones

My code looks like this and is not working at all:

<td>& " Substitute(Substitute(Substitute(@{items('Apply_to_each_2')?['officers']},";",""),"* *","")," "," ")" &</td>

 

The 2nd thing I am trying to achieve is to format the status cell with a red background and bold white font color IF the value of status is equal to Pending - this the code I have for that one:

<td & if equals item()?['@{items('Apply_to_each_2')?['status/Value']}'],'Pending',style=''background-color:red; color:white; font-weight:bold''','')>@{items('Apply_to_each_2')?['status/Value']}</td>    see Flow-detail.PNG as well

 

any assistance greatly appreciated thank you

  • bobgodin Profile Picture
    bobgodin 353 on at
    Re: Trying to format cells in an HTML table based on status value and using substitute to separate names in a string

    I have made some progress on the above problem and have managed to get the word "Pending" formatted in red in the Status column of my HTML table. However this is what I get:

    {"Status":"Approved"}

    [{"Status":"Pending"}]

    so, my syntax is a little wrong obviously

     

    can anyone help please @Reza @WarrenBelz

  • bobgodin Profile Picture
    bobgodin 353 on at
    Re: Trying to format cells in an HTML table based on status value and using substitute to separate names in a string

    Update: I have resolved the 1st problem I had by using Replace instead of Substitute (I found out that Substitute is not a supported function in Power Automate)

     

    For the benefit of others viewing this post I used a Compose action on the Officers field (which has multiple names in a string) and this code to replace the semi colons and asterisks with nothing:

    replace(replace(items('Apply_to_each_2')?['officers'],';',''),'* *','')
     
    I haven't had any responses regarding my 2nd problem (trying to format a cell font colour if the value was equal to Pending) although I studied a video that Reza Dorrani has where he changed the font colour based on the value in that cell - I copied the code and tried it but it failed saying I had only 1 condition in the If statement instead of 3
    My code for the If statement is in the 1st attachment and the 2nd attachment is a screenshot of the error I am getting.
     
    My If statement is: 
    if(equals(items('Apply_to_each_2')?['status/Value'],'Pending','Red','Black'))
  • bobgodin Profile Picture
    bobgodin 353 on at
    Re: Trying to format cells in an HTML table based on status value and using substitute to separate names in a string

    @lbendlin I only have the one single quote character on my keyboard - the one below the double quote character - that's the one I am using....

  • lbendlin Profile Picture
    lbendlin 7,821 on at
    Re: Trying to format cells in an HTML table based on status value and using substitute to separate names in a string

    make sure to use the straight single quote, not any of the slanted accents.

  • bobgodin Profile Picture
    bobgodin 353 on at
    Re: Trying to format cells in an HTML table based on status value and using substitute to separate names in a string

    @lbendlin thanks for that

    when I try that I get the attached result in the HTML table - notice how the ' character is going into the next table definition.....I must have missed something...

  • lbendlin Profile Picture
    lbendlin 7,821 on at
    Re: Trying to format cells in an HTML table based on status value and using substitute to separate names in a string

    sort of.  Note that PowerAutomate uses single quotes, not double quotes.

     

    more like this

     

    '<td>' &  Substitute(Substitute(@{items('Apply_to_each_2')?['officers']},';',''),'* *','') & '</td>'

  • bobgodin Profile Picture
    bobgodin 353 on at
    Re: Trying to format cells in an HTML table based on status value and using substitute to separate names in a string

    @lbendlin Hi - do you mean put quote characters like this:

    '<td>'& " Substitute(Substitute(Substitute(@{items('Apply_to_each_2')?['officers']},";",""),"* *","")," "," ")" &'</td>'

     

  • lbendlin Profile Picture
    lbendlin 7,821 on at
    Re: Trying to format cells in an HTML table based on status value and using substitute to separate names in a string

    you need to treat the HTML code as text.

     

    So instead of 

     

    <td>

     

    you need to use

     

    '<td>'

     

    etc.

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,246

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,884

Leaderboard