Forum Discussion

SL12345's avatar
SL12345
New Contributor III
3 years ago
Solved

Email sender - Change table row color based on value

Hi snaplogic experts,

is it possible to change table row in email body based on current value ? in my example i retrieve email with values - but is it possible to mark whole row as green, if revenue is higher as e.g. $5000?
just to make email readable

my example:

<!DOCTYPE html><html><head><style type="text/css"> </style></head>
<body>
<table>
<tr>
<th>Branch</th>
<th>City</th>
<th>Revenue</th>
</tr>
<tr>
<td>$branch</td>
<td>$city</td>
<td>$revenue</td>
</tr>
</table>
</body>
</html>

thank you

  • Hi @SL12345,

    Yes, it’s possible by using apache velocity.

    I’m sharing a code I used in one of my pipelines. I believe you’ll be able to tweak it per your requirements:

    <tr>
                <td>Actual Values</td>
                #foreach($key in $line.thresholds.keySet())
                    #if($line.stats.get($key) > $line.thresholds.get($key))
                <td style="background:tomato">$line.stats.get($key)</td>
                    #else
                <td>$line.stats.get($key)</td>
                    #end
                #end
            </tr>
    

    This one colors the background in red if a specific condition is fulfilled , if not, than no color is used.

1 Reply

  • bojanvelevski's avatar
    bojanvelevski
    Valued Contributor

    Hi @SL12345,

    Yes, it’s possible by using apache velocity.

    I’m sharing a code I used in one of my pipelines. I believe you’ll be able to tweak it per your requirements:

    <tr>
                <td>Actual Values</td>
                #foreach($key in $line.thresholds.keySet())
                    #if($line.stats.get($key) > $line.thresholds.get($key))
                <td style="background:tomato">$line.stats.get($key)</td>
                    #else
                <td>$line.stats.get($key)</td>
                    #end
                #end
            </tr>
    

    This one colors the background in red if a specific condition is fulfilled , if not, than no color is used.