How to override the "Send an Email" button on the Case object - Emails related list
In order to change the link URL for the New Email
button, you have to use a Javascript hack. Create a new "narrow" Homepage Component (really a Sidebar component, but SFDC calls them Homepage components) and paste the following code in (be sure to check off Show HTML
first, so that this is entered as code, not as text)
<div id="remove-shortcut-id">
Click "Show HTML" to see hidden javascript code.<br/>
<b>DO NOT SAVE UNLESS JAVASCRIPT IS VISIBLE</b> or else that code will be erased.
</div>
<script type="text/javascript"><!--
function changeNewEmailQuery() {
var PARAMETERS_TO_ADD = 'p26=add_it_here&other=if_another_one';
var cid = window.location.pathname.replace('\/', '');
if (cid.indexOf('500') != 0) return;
var newEmailBtn = document.getElementsByName("newEmail");
if (newEmailBtn[0] && newEmailBtn[0].query_fixed == false) {
var btn = newEmailBtn[0];
var fn = btn.onclick.toString()
var navUrl = fn.match(/navigateToUrl\('([^']*)'.*/)[1];
navUrl = navUrl + "&" + PARAMETERS_TO_ADD;
btn.onclick = function (event) { navigateToUrl(navUrl, null, 'newEmail'); };
btn.query_fixed = true;
}
}
/* Run immediately on page load and queue for second run after related lists load */
changeNewEmailQuery();
setTimeout('changeNewEmailQuery();', 100);
/* hide this component */
document.getElementById('remove-shortcut-id').parentElement.style.display = 'none';
--></script>
Save this component and add it to your Homepage layout as a narrow column. The code will run on each page load, and whenever it sees the NewEmail, it will edit the query string.
(Fixed doublequote issue)
Wont work in Summer '14 release since the 'showHTML' feature has been disabled for HTMLarea component types for Homepage layouts