I have been trying to figure out how I can make the "Send Notification Email" checkbox checked by default when changing the owner of a Case record in Salesforce. I know that you can toggle this from within the Case page layout editing screen, however there is a flaw with this option. It will default the checkbox to checked when you initially go to change an owner of a Case, however if you change the owner type to "Queue", the checkbox is immediately unchecked again. This is causing issues for us because our Support team are not realizing that the box is being unchecked when changing the owner type, so the notification is not getting sent.
I have attempted to correct this by adding some javascript to this page in the form of a Home Page Component, although I can only get it to act like Salesforce's flawed system where it will not stay checked once you change the owner type. Here is my javascript code.
window.onload = function()
{
if(window.location.href.indexOf('/500') != -1 && document.getElementById('sendMail'))
{
document.getElementById("sendMail").checked = true;
};
};
Is there something I can add to this code to keep the checkbox checked when the owner type is modified? I also want to keep the ability of unchecking the box as well, but I want the Support user to have to manually uncheck the box since it would always be checked by default.
This is the final version of the code which works perfectly for defaulting the "Send Notification Email" checkbox to checked.
<script type="text/javascript">var originalOnLoad = window.onload;
window.onload = workaround;
function workaround(){
originalOnLoad();
document.getElementById("notifier").parentNode.parentNode.style.display = "none";
if (window.location.href.indexOf('/500') != -1 && document.getElementById('sendMail')) {
document.getElementById("sendMail").checked = true;
var ele = document.getElementById("newOwn_mlktp");
ele.addEventListener("change", checkSendEmail, false);
}
};
function checkSendEmail() {
document.getElementById("sendMail").checked = true;
}</script>
<a id="notifier"></a>
window.location.href.indexOf('CaseMassAction')
in the condition.