Summary:

Carrying out an action on an email before the email body has loaded may result in the word "null" being displayed in the editor.

Cause:

The editor screen is referred to as the FCKEditor. Clicking any of the Send E-mail, Send Anyway, Send Using Outlook, Send Anyway using Outlook and Delete Attachment buttons before the FCKEditor has completed loading may cause the error to occur.

As a result of clicking any of these buttons, a request goes out for the FCKEditor to reload the email. A separate request is sent out to load the CRM user interface. If the request to load the interface is completed before the FCKEditor loads, and the user carries out an action, then the error will occur.

Long delays in loading the email record may indicate an issue with general performance in CRM. It may be worthwhile checking for a general CRM performance issue on the Communications table if the email takes more than about a second to be displayed.

The Fiddler HTTP debugger has a Statistics tab which should tell you how long it took a HTTP request to be fulfilled.

 Fiddler statistics

Between that and the CRM logs, it should be possible to determine if the delay in fulfilling these requests is happening on the server. If it’s not, then it’s possible that there’s a delay on the client – the HTML and scripts returned by the server have to be processed before the page has finished loading. The Profile/Profiler tab in the Developer Tools for any browser should be able to help with this.

One way of working around this issue is to make sure that there’s always a value available for the email body before we allow one of these actions to be run. The workaround listed below will do a check whether the FCKEditor has loaded or not, and add a check to the Delete Attachment and Send buttons. If the FCKEditor has not loaded yet, then clicking these buttons will do nothing.


Resolution:

The following workaround script can be added as a Custom Content script on EmailFilingBox. The script disables the Send E-mail, Send Anyway, Send Using Outlook, Send Anyway using Outlook and Delete Attachments buttons until the FCKEditor has loaded.

<script>
function CheckIFrameLoaded () {

    if (isBlankUndefinedOrNull(escape(window.frames["iframebody"].getBodyText()))) {

        return false;
    }
    else return true;
}

function DeleteFileCheckLoaded (filename, event)  {

    // If the IFrame isn't loaded yet, then just kill the button action

    if (!CheckIFrameLoaded ()) {

        return;
    }

    document.EntryForm.comm_email.value = escape(window.frames["iframebody"].getBodyText());

    if (window.frames["iframebody"].isEditMode() == 'Y')
        document.EntryForm.EditSource.value='Y';
    else document.EntryForm.EditSource.value='';

    document.EntryForm.action+="&DeleteFile=Y&FileName="+filename;
    document.EntryForm.submit();
    event.returnValue=false;
}

function isBlankUndefinedOrNull (val) {

    if ( (val+"")=="" ||
        (val+"")=="undefined" ||
        (val+"")=="null") {

        return true;
    }
    else return false;
}

$(document).ready(function () {

    var arrOnClick = $("img[src*='SmallRemove.gif']").map(function() {
                return $(this).parent().attr("onclick");
    }).get();

    var targetLinks = $("img[src*='SmallRemove.gif']").parent();

    for (var i=0; i<targetLinks.length; i++) {

        targetLinks[i].onclick = new Function(arrOnClick[i].replace(/DeleteFile/,"DeleteFileCheckLoaded"));
    }

    // Add the check to the remaining mail links

    var allLinks = document.getElementsByTagName("a");

    for (var i=0; i<allLinks.length; i++) {

        if (allLinks[i].href.indexOf("if (canSubmitEmail() == true)")>-1) {

            allLinks[i].href = allLinks[i].href.replace("javascript:if (canSubmitEmail() == true)", "javascript:if ((canSubmitEmail() == true) && CheckIFrameLoaded())");
        }
        else if (allLinks[i].href.indexOf("javascript:document.forms[0].sendanyway.value='Y';Submit")>-1) {

            allLinks[i].href = allLinks[i].href.replace("javascript:", "javascript:if(CheckIFrameLoaded()){ ") + " }";
        }
    }
});
</script>


Status:

This issue has been assigned to the development team, with a fix scheduled for v7.2f.

More information:

A similar issue is described in KBA 255-14591. The workaround provided in this article makes use of code changes in v7.1, and applied a workaround to more email actions.