Summary:

In CRM, deleting a large number of attachments in quick succession can result in the word null appearing in the FCKEditor window.

Symptoms:

The issue can be replicated by filing an email with a large number of attachments from Outlook to CRM. In CRM, the email can be forwarded, and a user can rapidly click Delete Attachment to remove the attachments.

Similar issues have occurred with other buttons (such as the "Send" buttons) - essentially, if the screen is submitted before the FCKEditor pane has finished loading, then the email content may be lost.

Workaround / Resolution:

The issue can be worked around by preventing the form from being submitted if the FCKEditor content has not loaded. The URLs or OnClick events for each target button are modified to include an additional check for this purpose. If the FCKEditor has not loaded, the click will be ignored.

The script should be added as a Custom Content script on EmailFilingBox.

1) Go to

<script>
// Disables actions that submit the email screen if the FCKEditor has not loaded
// Add as a Custom Content script to EmailFilingBox

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())");
        }
    }
});
</script>