The CreatorCon Call for Content is officially open! Get started here.

Request: How to add conditional logic to the email_client

justin_drysdale
Mega Guru

Per the wiki: "The email client uses its own email templates to define default values for fields. You can create a different template for each table that uses the email client. "

Is it possible to add conditional logic to the template? Creating a new table just for a custom template is not an action worth considering.

I am aiming to pre-populate the "To:" field with a Distribution List appended on after the caller_id if and only if the assignment_group field (from the incident table) has a certain value.

I've attached a screenshot from the wiki to better illustrate my question.

Any advice is appreciated.

3 REPLIES 3

justin_drysdale
Mega Guru

I just realized that I have access to mail_script in the template. I can probably use it to 1st query the incident for the value, and if found override the To: field. I would still appreciate any advice.


justin_drysdale
Mega Guru

I implemented the following in the Body field of the client template for incidents:


gs.log("Hi From the email client template");
var field = current.assignment_group.getDisplayValue();
gs.log(field);
if(field == "MyGroup") {
email.setTo(current.caller_id.email + ";" + "MyDList@Domain.com");
}else{
email.setTo(current.caller_id.email);
}



However it fails miserably. For whatever reason, inside a client template email.set* overrides don't work like they do inside a regular email template. No error is produced in the logs.

I change the script to a simple template.print("test text"), "test text" shows up fine in the Body field of the email_client.



User166992
Tera Guru

Hi,

You can customize Email Client Template form to include condition.
Refer attached images.

Regards,
Jaikumar