Variable to color banded depending on teh value in email template

Shree Nag
Tera Expert

hello,

Appreciate your help in advance.

I'm trying to color band a variable "Priority" that is included in the email message script.

Depending on Low, high medium, I need to color band only teh Priority varble.

Could you please help me with the script.

 

var PriorityIs=${sysapproval.priority}
if (PriorityIs="medium")
{
Priority: ${sysapproval.priority} // Color should be orange
}else if
{
if (PriorityIs="high")
Priority: ${sysapproval.priority} // Color should be Red
}

 

 I tried the below code, but not seeing teh color:

 

var PriorityIs=${sysapproval.priority}
if (PriorityIs="medium")
{
<span style='color:orange'>Priority: ${sysapproval.priority} </span> // Color should be orange
}else if
{
if (PriorityIs="high")
<span style='color:red'>Priority: ${sysapproval.priority} </span> // Color should be red
}

 

 

Please help.

1 ACCEPTED SOLUTION

Rafael Batistot
Kilo Patron

Hi @Shree Nag 

Consider this solution 

var priority = current.priority + "";
var coloredPriority = "";

if (priority == "3") { // Medium
    coloredPriority = "<span style='color:orange;'>Priority: " + priority + "</span>";
} else if (priority == "1") { // High
    coloredPriority = "<span style='color:red;'>Priority: " + priority + "</span>";
} else {
    coloredPriority = "Priority: " + priority;
}

email.body = email.body.replace("${priority_placeholder}", coloredPriority);



View solution in original post

1 REPLY 1

Rafael Batistot
Kilo Patron

Hi @Shree Nag 

Consider this solution 

var priority = current.priority + "";
var coloredPriority = "";

if (priority == "3") { // Medium
    coloredPriority = "<span style='color:orange;'>Priority: " + priority + "</span>";
} else if (priority == "1") { // High
    coloredPriority = "<span style='color:red;'>Priority: " + priority + "</span>";
} else {
    coloredPriority = "Priority: " + priority;
}

email.body = email.body.replace("${priority_placeholder}", coloredPriority);