11

On the Case object page, there is an Emails related list which has a Send an Email button taking the user to another page to fill in the email.

I haven't been able to find a way to override the functionality of this Send an Email button, or customise the Emails related list in any way. All I want to do is to manipulate the URL onclick so that the p26 parameter is set which will set the email From: address to a certain value.

I have done this by creating a custom Send an Email button and adding it to the Case page, but the Send an Email button on the Emails related list is still there of course, so if users press that one then they don't get the custom functionality.

Is there anyway I can override the default functionality, or remove the standard Send an Email button?

Thanks

9

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)

  • nice, but I would suggest to append the additional parameter to the value of the onClick event instead of just hiding the button. and by the way although we use the javascript sidebar components all the time this is not an officially supported or recommended approach. changes in upcoming releases that affect the html of the standard layout may break the functionality. anyway i like these little ui hacks :-) – h9nry Sep 6 '12 at 12:16
  • @h9nry good point! I'll try to come back and edit this later today, or am happy to accept recommended edits. – Benj Sep 6 '12 at 12:19
  • 1
    I've made the changes. – Benj Sep 6 '12 at 12:55
  • Hi. Thanks for the very detailed answer. I understand the JavaScript fine, but would like to ask a few questions to understand what is going on. You can add custom components to the home page, but not to the Case page. Won't the JavaScript only run if the user goes to the Home page first before going to a Case. Will the function still be in memory by that time? If the custom component is added to the Home page and the changeNewEmailQuery function runs, how will document.getElementsByName("newEmail"); work when there isn't a button on the Home page? I'm probably missing something here. – Joe Sep 7 '12 at 11:26
  • 2
    @Joe, it's a confusing naming thing -- components that are part of the Sidebar (which is loaded for every page) are configured as "Narrow Home Page Components" in the Salesforce setup. So while it's called a Home Page component, it's really in the Sidebar and this code is loaded and run on every page load. if (cid.indexOf('500') != 0) return; limits the execution to the Case page. – Benj Sep 7 '12 at 12:26
2

Wont work in Summer '14 release since the 'showHTML' feature has been disabled for HTMLarea component types for Homepage layouts

0

I believe you will have to remove the button from the related list and add your own custom button.

1) To remove the button when in the edit layout page

  • Click the small spanner top left of the Email Object Related List
  • At the bottom of the light window that appears is a folded up section called Buttons, Click the '+' symbol
  • Untick the Send an Email standard button.

2) Create a new button for the Email Object that uses the custom link that you need

  • 2
    have you tried this yourself? as joe already mentioned it is not possible to customize email related list. no offense but i think this in not very helpful. – h9nry Sep 6 '12 at 11:50
  • I haven't tested this myself as I don't have the Email object on my personal dev instance. I made several attempts to write the above clearly and I left out any comment that it hadn't been tested. My Apologies! If thats the case then there I dont really have an answer to the question :/ All I can suggest is to build your own VF page to display the data – Jon Hazan Sep 6 '12 at 12:11
  • @Jon - Thanks for your reply. Unfortunately, it doesn't seem possible to customize the Email related list. For instance, unlike the other related lists, there isn't the spanner that you mention. – Joe Sep 6 '12 at 16:20
0

Possible workaround is to simply remove "Send An Email" on the related list. Create a custom button on the CASE record itself not the activity history related list, not a direct port of the feature but workable anyways

0

This cannot be done. The Send an Email button on the Emails related list cannot be removed, customized, or otherwise modified. I attempted this. It took me a while to find the answer, but it isn't possible. Some answers will advise you to modify the Activity History related list. This can be done but there will be 2 Send an Email buttons on you Case record with 2 different functionalities. You can remove the Emails related list altogether in favor of keeping only the Send an Email button on the Activity History related list, but be warned this removes all inbound emails from the record.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.