Request: How to add conditional logic to the email_client
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2012 03:12 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2012 03:20 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2012 04:13 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-31-2012 06:14 AM