Conditionally change font color based on smart value in HTML Email

Randy Simes April 15, 2024

I have an HTML table generated from Lookup Issues values. I'm trying to print some of the values in Red when they are >= 50. I've gotten some success but not consistent. For instance, when the value is 13, it prints in black as expected. When the value is 67 it prints in red which is expected. When the value is 137, it prints in green which is unexpected. 

<td align="center"> <font color="{#if {{created.diff(now).days}} < 50}black{#else}red{#/if}"> {{created.diff(now).days}} </font> </td>

My Outlook client did not change any of the colors when trying the CSS formatting:
<td align="center" style="color: {#if {{created.diff(now).days}} > 50}red{#/if}"> {{created.diff(now).days}} </td>

1 answer

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 15, 2024

Hi @Randy Simes 

For a question like this, please post an image of your complete automation rule, images of any relevant actions / conditions / branches, an image of the audit log details showing the rule execution, and explain what is not working as expected.  Those will provide context for the community to offer ideas.  Thanks!

Until we see those...

I wonder if the HTML conditional logic is not working due to data type from the diff() function result.  Perhaps try using inline, conditional logic for the smart value.  Here is an example:

<td align="center"> <font color={{if(created.diff(now),"black","red")}}> {{created.diff(now).days}} </font> </td>

Kind regards,

Randy Simes April 15, 2024

I was just able to get this to work using the following:
{{#if (created.diff(now).days.gte(50))}}<td align="center"><font color="red">{{created.diff(now).days}}</font></td>{{/}}
{{#if (created.diff(now)}}<td align="center"><font color="black">{{created.diff(now).days}}</font></td>{{/}}

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events