Email Template - Restrict based on Lead/Contact

Hey there,

I needed help for a way to restrict e-mail templates.
Therefore if Lead is selected in “related to” then only x nos. of templates are displayed.
If Contacts is selected in “related to” then only y nos. of templates are displayed.

Thanks in advance.

Again could probably be done with javascript by disabling all the unwanted options in the template dropdown based on what is selected in related to.

Otherwise if you want it to be more robust than that and build it into the system then its alot of work, far beyond the scope of a non-developer.

Hi Andrew,

Yup, figured that one out. I kinda also have a skeletal jqurey for it.

I just wanted to know how to call the jqurey?

I mean, email quick compose ain’t got no detailview/editview defs.
In fact it itself is a java pop-up, that gets called from modules/Emails/javascript/EmailUICompose.js and modules/Emails/javascript/composeEmailTemplate.js

Thanks in advance.

—Continued

For example when I click the compose email button from within the context of another module’s detail view (Leads/Contacts) the quick compose modal window comes up.
Therefore how would I call the custom jquery from the modal window.

Ah I see what you mean, I was thinking you were talking about something in the standard email module. Yeah the quick compose window is done in JavaScript and what you want to do is going to be fairly difficult id imagine. I’ve never actually had to modify that myself.

What I can tell you is there are two files I found related to this:

jssource/src_files/include/javascript/quickCompose.js

modules/Emails/javascript/EmailUICompose.js

You will have to alter the js in those to suit your needs but I don’t recommend it as its not going to be upgrade safe.

Hi Andrew,

If editing the js files ain’t upgrade safe then what other method would you recommend?

Not sure TBH, I probably would’nt bother with such a modification.

I got it to work as below.

$(document).bind(‘DOMNodeInserted’, ‘#composeHeaderTable0’, function(event) {
if ($(’#data_parent_type0’).val() == ‘Leads’) {
$("#email_template0 option[value=‘templateiduwanttohide’]").hide();
}
});

You need to call the js from the view, in my case custom/modules/Leads/metadata/detailviewdefs.php

Hope this is helpful to others who are encountering the same.

Best,

John