Summary:

Time selection drop down menus will not work in Sage CRM 7.3c when Compatibility View is enabled.

Symptoms:

The issue can be observed on either the New Task or New Appointment screens when the dropdown associated with the time part of the Due Date/Time field is selected. When dunctioning, the menu should be displayed as follows:

Due time dropdown 



Cause:

Internet Explorer Compatibility View is not strictly supported with Sage CRM 7.3 as per the support matrix. However, there are circumstances where Compatibility View must be used for other applications hosted on the Sage CRM server.

The issue is caused by CRM serving up legacy Internet Explorer code making use of the deprecated createPopup() JavaScript function. This is only  done when a user logs in using a legacy version of Itnernet Explorer, or a version making use of Compatibility View. Many Sage CRM screens contain the X-UA-Compatible header set to Edge mode, which causes the deprecated JavaScript to throw an error.

In effect, Sage CRM should always be running in Edge mode regardless of the chosen compatibility level; the legacy code should not be served to the client.


Status:

The issue has been rasied as a bug to the development team.


More information:

The issue can be owkred around by using a number of different methods.

Firstly, separate browsers might be used for Sage CRM an other applications hosted on the same server, where those applications only support legacy versions of Internet Explorer.

A second method is to add DNS records to the customer's domain, so that the CRM Server and other applications are seemingly accessed on different hosts. This will allow Internet Explorer to be set to use Compatibility View for one application and not the other.

A third option is to add the following JavaScript as a Custom Content script on CommunicationSchedulingBox. It will resolve the issue on the New Task and New | Appointment screens, but will not affect any other instances of datetime fields in CRM.


<script>
crm.ready(function () {

    /*
        Workaround for issues with three dropdowns for three fields on the New | Task screen
        These issues occur when using Compatibility View in IE 11.

        comm_datetime_TIME
        comm_todatetime_TIME
        comm_notifytime_TIME
       
        Add as a Custom Content script to CommunicationSchedulingBox
   
        A similar script can be used for the New | Appointment screen, though you may want to
        add logic to select a specific time when the dropdown is ticked
    */

    // Quick test for compatibility. not obvious due to X-UA-Compatible header
   
    if ((document.documentMode>=11) && (($("body").html().indexOf("create"+"Popup()"))>-1)) {

        console.log("Workaround to Sage CRM L3 case 0-165447 being applied");

        var strFFDiv = '<DIV ID="FIREFOX_CALENDAR_LAYER" '
            + 'style="position:absolute; padding-left:0px;padding-top:0px;width:205px;height:145px;visibility:hidden">'
            + '<DIV ID="CALSOURCE">'
            + '</div>';
       
        $('#EntryForm').append(strFFDiv);

        // Change event handlers
       
        if ($('#_IMG_comm_datetime_TIME').length) {
       
            oPopup_comm_datetime_TIME = null;

            $('#_IMG_comm_datetime_TIME').click( function () {
       
                if (document.getElementById('comm_datetime_TIME').disabled == false) {
   
                    DropDown_comm_datetime_TIME_Workaround();

                    if(parent&&parent.frames['EWARE_MENU']) fn=parent;
                    else SetDateDropDownFromField_Workaround('comm_datetime_TIME', oPopup_comm_datetime_TIME,document);
                }
            });
        }
       
        if ($('#_IMG_comm_todatetime_TIME').length) {
       
            oPopup_comm_todatetime_TIME = null;
       
            $('#_IMG_comm_todatetime_TIME').click( function () {
               
                if (document.getElementById('comm_todatetime_TIME').disabled == false) {
           
                    DropDown_comm_todatetime_TIME_Workaround();

                    if(parent&&parent.frames['EWARE_MENU'])fn=parent;
                    else SetDateDropDownFromField_Workaround('comm_todatetime_TIME', oPopup_comm_todatetime_TIME,document);
                }
            });
        }
   
        if ($('#_IMG_comm_notifytime_TIME').length) {
       
            oPopup_comm_notifytime_TIME = null;
       
            $('#_IMG_comm_notifytime_TIME').click( function () {
               
                if (document.getElementById('comm_notifytime_TIME').disabled == false) {
           
                    DropDown_comm_notifytime_TIME_Workaround();

                    if(parent&&parent.frames['EWARE_MENU'])fn=parent;
                    else SetDateDropDownFromField_Workaround('comm_notifytime_TIME', oPopup_comm_notifytime_TIME,document);
                }
            });
        }
    }
});

function changevalue_Workaround(ffrom, fto) { 
       
    fto.value = ffrom.value;
    var hiddenobj = document.getElementById("FIREFOX_CALENDAR_LAYER");
    hiddenobj.style.visibility = "hidden";
    fto.onchange();
};
       
       
function keydownHandler_Workaround(e) {

    if (e.keyCode==27)  {
       
        var hiddenobj = document.getElementById("FIREFOX_CALENDAR_LAYER");
        hiddenobj.style.visibility = "hidden";

        document.onkeypress = evtHandler;
       
        return true;
    }
    else if (e.keyCode == 9)
        return false; 
}

function DropDown_TIME_Generic_Workaround (inputElemId) {

    if (!window.closeTimePopUpOnScroll) {

        var handler = window.closeTimePopUpOnScroll = function () {
            $("#FIREFOX_CALENDAR_LAYER")[0].style.visibility = "hidden";
            $("#EWARE_MID").unbind("scroll", handler);
            window.closeTimePopUpOnScroll = false;
        };

        $("#EWARE_MID").scroll(handler);
    }

    if($('#EWARE_MENU').length > 0)
        fn=parent;

    else { if(opener != null) fn=opener.parent;    }

    evtHandler = document.onkeypress;

    var hiddenobj = document.getElementById("FIREFOX_CALENDAR_LAYER");
    hiddenobj.style.position= "absolute";

    var oElement = document.getElementById(inputElemId);

    var position = $(oElement).position();

    hiddenobj.style.left = Math.round(position.left) + "px";
    hiddenobj.style.top = Math.round(position.top + $(oElement).outerHeight() + 2) + "px";
    hiddenobj.style.width="60px";
    hiddenobj.style.visibility = "visible";

    document.onkeypress = keydownHandler_Workaround;

    document.getElementById("CALSOURCE").innerHTML = '<div style="position:relative;left:-1px;top:-1px;" '
        + 'id="myLayer_' + inputElemId + '" class="VIEWBOX">'
        + '<SELECT class="EDIT" size=10 name="' + inputElemId + '_DD" id="' + inputElemId + '_DD"  '
        + 'onChange=" changevalue_Workaround(' + inputElemId + '_DD, '
        + 'document.getElementById(&quot;' + inputElemId + '&quot;));"'
        + 'onclick="changevalue_Workaround(' + inputElemId + '_DD, document.getElementById(&quot;' +  + '&quot;) );" '
        + 'onblur="">'
        + '<OPTION Value="00:00">00:00</OPTION><OPTION Value="00:30">00:30</OPTION>'
       + '<OPTION Value="01:00">01:00</OPTION><OPTION Value="01:30">01:30</OPTION>'
        + '<OPTION Value="02:00">02:00</OPTION><OPTION Value="02:30">02:30</OPTION>'
        + '<OPTION Value="03:00">03:00</OPTION><OPTION Value="03:30">03:30</OPTION>'
        + '<OPTION Value="04:00">04:00</OPTION><OPTION Value="04:30">04:30</OPTION>'
        + '<OPTION Value="05:00">05:00</OPTION><OPTION Value="05:30">05:30</OPTION>'
        + '<OPTION Value="06:00">06:00</OPTION><OPTION Value="06:30">06:30</OPTION>'
        + '<OPTION Value="07:00">07:00</OPTION><OPTION Value="07:30">07:30</OPTION>'
        + '<OPTION Value="08:00">08:00</OPTION><OPTION Value="08:30">08:30</OPTION>'
        + '<OPTION Value="09:00">09:00</OPTION><OPTION Value="09:30">09:30</OPTION>'
        + '<OPTION Value="10:00">10:00</OPTION><OPTION Value="10:30">10:30</OPTION>'
        + '<OPTION Value="11:00">11:00</OPTION><OPTION Value="11:30">11:30</OPTION>'
        + '<OPTION Value="12:00">12:00</OPTION><OPTION Value="12:30">12:30</OPTION>'
       + '<OPTION Value="13:00">13:00</OPTION><OPTION Value="13:30">13:30</OPTION>'
        + '<OPTION Value="14:00">14:00</OPTION><OPTION Value="14:30">14:30</OPTION>'
        + '<OPTION Value="15:00">15:00</OPTION><OPTION Value="15:30">15:30</OPTION>'
        + '<OPTION Value="16:00">16:00</OPTION><OPTION Value="16:30">16:30</OPTION>'
        + '<OPTION Value="17:00">17:00</OPTION><OPTION Value="17:30">17:30</OPTION>'
        + '<OPTION Value="18:00">18:00</OPTION><OPTION Value="18:30">18:30</OPTION>'
        + '<OPTION Value="19:00">19:00</OPTION><OPTION Value="19:30">19:30</OPTION>'
        + '<OPTION Value="20:00">20:00</OPTION><OPTION Value="20:30">20:30</OPTION>'
        + '<OPTION Value="21:00">21:00</OPTION><OPTION Value="21:30">21:30</OPTION>'
        + '<OPTION Value="22:00">22:00</OPTION><OPTION Value="22:30">22:30</OPTION>'
        + '<OPTION Value="23:00">23:00</OPTION><OPTION Value="23:30">23:30</OPTION>'
        + '</SELECT> </div>';

     openingDropDown = true;
}


function DropDown_comm_datetime_TIME_Workaround () {

    DropDown_TIME_Generic_Workaround("comm_datetime_TIME");
}

function DropDown_comm_todatetime_TIME_Workaround () {
               
    DropDown_TIME_Generic_Workaround("comm_todatetime_TIME");
}

function DropDown_comm_notifytime_TIME_Workaround () {
       
    DropDown_TIME_Generic_Workaround("comm_notifytime_TIME");
}

function SetDateDropDownFromField_Workaround(timeField, popOut,Doc) {

    if(Doc)ed=Doc;
    else ed=parent.frames[6].document;
    var sUsePM=0;
    sVar=ed.all(timeField).value;
   
    if(sVar=='') { sVar='15:58'; }
   
    sVar=sVar.toUpperCase();
    var nHr=0;
    var aVar1=sVar.replace(" ",":");
    var aVar=aVar1.split(":");
    iHr='0000'+aVar[0];
    iMin='0000'+aVar[1];
    iHr=iHr.substring(iHr.length-2,iHr.length);
    iMin=iMin.substring(iMin.length-2,iMin.length);
    iAMPM=aVar[2];
    iSet='00';
   
    if (iMin>15 && iMin<=45) { iSet='30' };
   
    if (iMin>45) {
   
        nHr=(iHr*=1)+1;  
       
        if (sUsePM==1) {
       
            if(nHr>12) { nHr=1; }
           
            if(nHr==12) {

                if (iAMPM=='AM') { iAMPM='PM'; }
                else { iAMPM='AM'};
            };     
        }  
        else{ if(nHr>23) { nHr=0; } }  
        iHr="00"+nHr;  
    }
   
    iHr='00'+iHr;
    iHr=iHr.substring(iHr.length-2,iHr.length);
    iSet='00'+iSet;
    iSet=iSet.substring(iSet.length-2,iSet.length);
   
    if (sUsePM==1) { tSet=iHr+':'+iSet+' '+iAMPM; }
    else { tSet=iHr+':'+iSet; }
   
    ed.getElementById(timeField+'_DD').value=tSet;
    return true;
}
</script>