This code is implemented in a CRM form OnLoad event. The form somehow opens up in the middle instead of the top. I was wondering if anyone here notices something in this code that may cause this behavior.
//<---Script Inserted by C360 Solutions,dt.12/2/2005--->
Runc360AlertJsScript();
RunOriginalJavaScript();//Existing Code goes here in the function
}
catch(e)
{
alert("There was an error with this field's customized event\u002e\n\nField\u003a crmForm\n\nEvent\u003a onload\n\nError\u003a" + e.description);
}
}
}
var xmlHttpReq;
function Runc360AlertJsScript()
{
var qs=location.search.substring(1,location.search.length);
var isValidForm = false;
if (qs.length == 0)
{
isValidForm= false;
}
else
{
isValidForm= true;
}
if(isValidForm)
{
var firstQueryStringName = qs.split("&")[0].split("=")[0];
if(firstQueryStringName=="id" || firstQueryStringName=="Id" || firstQueryStringName=="ID")
{
isValidForm = true;
}
else
{
isValidForm = false;
}
}
if(!isValidForm)
{
return;
}
else if(IsOnline())
{
xmlHttpReq = CreateXmlHttpObject();
if(xmlHttpReq)
{
xmlHttpReq.onreadystatechange = processReqChange;
reqStr = "M=CheckAlerts&Record=" + crmForm.ObjectId.toString();
var url = "/c360/Alerts/ProcessAlerts.aspx";
url = IsOutlookLaptopClient() ? " + url : url ;
xmlHttpReq.Open("POST", url, true);
xmlHttpReq.setRequestHeader("Content-Type", "application/x-
xmlHttpReq.setRequestHeader("Content-Length", reqStr.length);
xmlHttpReq.send(reqStr);
}
}
}
function CreateXmlHttpObject()
{
// try to create a new instance of the xmlhttprequest object
try
{
// Internet Explorer
if( window.ActiveXObject )
{
for( var i = 5; i; i-- )
{
try
{
// loading of a newer version of msxml dll (msxml3 - msxml5) failed
// use fallback solution
// old style msxml version independent, deprecated
if( i == 2 )
{
xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" );
}
// try to use the latest msxml dll
else
{
xmlHttp = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" );
}
break;
}
catch( excNotLoadable )
{
xmlHttp = false;
}
}
}
}
catch( e )
{
xmlHttp = false;
}
return xmlHttp;
}
function processReqChange()
{
try{
// "complete"
if(xmlHttpReq.readyState == 4)
{
// "OK"
if(xmlHttpReq.status == 200)
{
AlertsExist( xmlHttpReq.responseXML.documentElement.getAttribute('AlertCount') );
}
}
}
catch(e)
{}
}
function AlertsExist(AlertCount)
{
if(AlertCount != "0")
{
var url = "/c360/Alerts/DisplayAlerts.aspx?RecordId=" + crmForm.ObjectId.toString();
url = IsOutlookLaptopClient() ? " + url : url ;
window.open(url ,null,"height=400,width=700,status=no,toolbar=no,menubar=no,location=no");
}
}
function RunOriginalJavaScript()
{
//<----------Existing code goes here --------------->
//set fields to hidden
document.getElementById("new_ssn_d").style.visibility = "hidden";
document.getElementById("new_ssn_c").style.visibility = "hidden";
// Ask the custom ASPX what the users role is
var oXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
oXmlDoc.async = false; // We want to wait for a response
oXmlDoc.load("/gbs/isv/DecisionResources/UserRoles/GetUserRoles.aspx");
// Load the result node
var oNodes = oXmlDoc.selectNodes("roles/role");
for(var i=0;i<oNodes.length;i++)
{
//alert(oNodes.item(i).text);
if (oNodes.item(i).text == "System Administrator" || oNodes.item(i).text == "Research Services")
{
//alert(oNodes.item(i).text);
document.getElementById("new_ssn_d").style.visibility = "visible";
document.getElementById("new_ssn_c").style.visibility = "visible";
}
}
}
</script>
<script>
{{
try {
//<---Script Inserted by C360 Solutions,dt.12/2/2005--->
Runc360AlertJsScript();
RunOriginalJavaScript();//Existing Code goes here in the function
}
catch(e)
{
alert("There was an error with this field's customized event\u002e\n\nField\u003a crmForm\n\nEvent\u003a onload\n\nError\u003a" + e.description);
}
}
}
var xmlHttpReq;
function Runc360AlertJsScript()
{
var qs=location.search.substring(1,location.search.length);
var isValidForm = false;
if (qs.length == 0)
{
isValidForm= false;
}
else
{
isValidForm= true;
}
if(isValidForm)
{
var firstQueryStringName = qs.split("&")[0].split("=")[0];
if(firstQueryStringName=="id" || firstQueryStringName=="Id" || firstQueryStringName=="ID")
{
isValidForm = true;
}
else
{
isValidForm = false;
}
}
if(!isValidForm)
{
return;
}
else if(IsOnline())
{
xmlHttpReq = CreateXmlHttpObject();
if(xmlHttpReq)
{
xmlHttpReq.onreadystatechange = processReqChange;
reqStr = "M=CheckAlerts&Record=" + crmForm.ObjectId.toString();
var url = "/c360/Alerts/ProcessAlerts.aspx";
url = IsOutlookLaptopClient() ? " + url : url ;
xmlHttpReq.Open("POST", url, true);
xmlHttpReq.setRequestHeader("Content-Type", "application/x-
xmlHttpReq.setRequestHeader("Content-Length", reqStr.length);
xmlHttpReq.send(reqStr);
}
}
}
function CreateXmlHttpObject()
{
// try to create a new instance of the xmlhttprequest object
try
{
// Internet Explorer
if( window.ActiveXObject )
{
for( var i = 5; i; i-- )
{
try
{
// loading of a newer version of msxml dll (msxml3 - msxml5) failed
// use fallback solution
// old style msxml version independent, deprecated
if( i == 2 )
{
xmlHttp = new ActiveXObject( "Microsoft.XMLHTTP" );
}
// try to use the latest msxml dll
else
{
xmlHttp = new ActiveXObject( "Msxml2.XMLHTTP." + i + ".0" );
}
break;
}
catch( excNotLoadable )
{
xmlHttp = false;
}
}
}
}
catch( e )
{
xmlHttp = false;
}
return xmlHttp;
}
function processReqChange()
{
try{
// "complete"
if(xmlHttpReq.readyState == 4)
{
// "OK"
if(xmlHttpReq.status == 200)
{
AlertsExist( xmlHttpReq.responseXML.documentElement.getAttribute('AlertCount') );
}
}
}
catch(e)
{}
}
function AlertsExist(AlertCount)
{
if(AlertCount != "0")
{
var url = "/c360/Alerts/DisplayAlerts.aspx?RecordId=" + crmForm.ObjectId.toString();
url = IsOutlookLaptopClient() ? " + url : url ;
window.open(url ,null,"height=400,width=700,status=no,toolbar=no,menubar=no,location=no");
}
}
function RunOriginalJavaScript()
{
//<----------Existing code goes here --------------->
//set fields to hidden
document.getElementById("new_ssn_d").style.visibility = "hidden";
document.getElementById("new_ssn_c").style.visibility = "hidden";
// Ask the custom ASPX what the users role is
var oXmlDoc = new ActiveXObject("Microsoft.XMLDOM");
oXmlDoc.async = false; // We want to wait for a response
oXmlDoc.load("/gbs/isv/DecisionResources/UserRoles/GetUserRoles.aspx");
// Load the result node
var oNodes = oXmlDoc.selectNodes("roles/role");
for(var i=0;i<oNodes.length;i++)
{
//alert(oNodes.item(i).text);
if (oNodes.item(i).text == "System Administrator" || oNodes.item(i).text == "Research Services")
{
//alert(oNodes.item(i).text);
document.getElementById("new_ssn_d").style.visibility = "visible";
document.getElementById("new_ssn_c").style.visibility = "visible";
}
}
}
</script>
<script>
{{
try {