web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Determine if Onload event of customized form is firing - or How do I debug it

(0) ShareShare
ReportReport
Posted on by 290

Good afternoon, we have a customized form and it does not seem to be utlizing the custom onload event. I really cant tell but thats what I am thinking.

This is the onload code, can anyone see if there is something wrong with it? Or if someone could tell me how to walk thru the form load that would be good as well.

/* ----- Start OnLoad ----- */

frmOnLoad();

onLoad = false;

}

catch(e)

{ alert(e.message); }

}//End of if condition

}//End of function

/* Declare Variables */

var onLoad = true;

var sGlobalVar = '';

function frmOnLoad()

{ ResizeScreen();

AddLogoToFormTitle(160, "/CRM4Legal/_imgs/reznick_small.gif");

fldMerge('name');

fldMerge('customerid');

fldMerge('rg_officeid');

fldStatus();

fldGSMC();

frmTabs();

frmNav();

frmIFrames();

if ($("rg_gsmc"  ) != null) $("rg_gsmc" ).onclick = fldGSMC;

}

function fldStatus()

{ with ( crmForm.all )

{ if ( statuscode.SelectedText == 'Won' || statuscode.SelectedText == 'Lost' )

{ crmForm.SetFieldReqLevel("rg_winlossreason", 1);

sectionDisplay( false, rg_winlossreason );

}

else

{ crmForm.SetFieldReqLevel("rg_winlossreason", 0);

rg_winlossreason.DataValue = null;

sectionDisplay( true, rg_winlossreason );

}

}

}

function fldGSMC()

{ with ( crmForm.all )

{ sectionDisplay( !rg_gsmc.DataValue, rg_contractnumber );

crmForm.SetFieldReqLevel("rg_contracttype", ( rg_gsmc.DataValue ? 1 : 0 ));

}

}

function fldMerge(fld)

{ if ( fld == null ) { return; }

var cell = $(fld + '_d');

if ( cell == null ) { return; }

var row = cell.parentNode;

if ( row == null ) { return; }

cell.colSpan = 3;

row.removeChild(cell.nextSibling);

row.removeChild(cell.nextSibling);

}

function frmTabs()

{ tab('Hidden', 'hidden');

}

function frmNav()

{ navHide ('nav_rg_opportunity_rg_opportunitypracticearea');

navHide ('nav_rg_opportunity_rg_opportunityservicearea');

navHide ('nav_rg_opportunity_rg_engagementteam');

navHide ('nav_rg_opportunity_rg_opportunityteam');

navHide ('navProducts');

navHide ('navQuotes');

navHide ('navOrders');

navHide ('navInvoices');

navHide ('navComp');

navHide ('_NA_SFA');}

function frmIFrames()

{ /* Engagement Team */

var n2nPA = new N2NViewer('IFRAME_EngagementTeam');  

/* Set the role order - use iedevtoolber for exact parameters */  

n2nPA.RoleOrder = 1;  

/* assing the relationship name (without the "area" word) */  

n2nPA.TabsetId  = "rg_opportunity_rg_engagementteam";  

n2nPA.Load();  

/* Opportunity Team */

var n2nPA = new N2NViewer('IFRAME_OpportunityTeam');  

n2nPA.RoleOrder = 1;  

n2nPA.TabsetId  = "rg_opportunity_rg_opportunityteam";  

n2nPA.Load();  

/* Practice Areas */

var n2nPA = new N2NViewer('IFRAME_PracticeAreas');  

n2nPA.RoleOrder = 1;  

n2nPA.TabsetId  = "rg_opportunity_rg_opportunitypracticearea";  

n2nPA.Load();  

/* Service Areas */

var n2nService = new N2NViewer('IFRAME_Services');  

n2nService.RoleOrder = 1;  

n2nService.TabsetId  = "rg_opportunity_rg_opportunityservicearea";  

n2nService.Load();  

}

function $(name)

{ return document.getElementById(name);

}

function navHide (name)

{ if ($(name) != null) { $(name).style.display = "none"; }

}

function tab ( tabName, tabVisibility )

{ tabVisibility = ( tabVisibility == "visible" ? "" : "none" );

var _tabs = crmForm.getElementsByTagName("li");

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

{ var _tab = _tabs[i];

if ( _tab.innerText == tabName )

{ _tab.style.display = tabVisibility;

break;

}

}

}

function sectionDisplay(vis, sec)

{ sec.parentElement.parentElement.parentElement.style.display = ((vis) ? 'none' : 'block');

}

function ResizeScreen()

{ var aH = screen.availHeight;

var aW = screen.availWidth;

var top = 0;

var left = 0;

if ( aW >= 1124 && aH >= 800)

{ var aH = (aH > 800 ? 800 : 768);

var aW = 1124;

var top = (screen.availHeight - aH) / 2;

var left = (screen.availWidth - aW) / 2;

}

// aH = (crmForm.FormType == frmType.Create ? 295 : aH);

window.moveTo(left, top);

window.resizeTo(aW, aH);

}

function N2NViewer(iframeId)  

{ if (!document.all[iframeId])  

{ alert(iframeId + " is missing!");  

return;  

}

var viewer = this;  

var _locAssocObj = null;  

viewer.IFRAME = document.all[iframeId];  

viewer.RoleOrder;  

viewer.TabsetId;  

viewer.Load = function()  

{   if (crmForm.ObjectId != null)

{ /* Construct a valid N2N IFRAME url */  

viewer.IFRAME.src = "areas.aspx?oId=" + crmForm.ObjectId + "&oType=" + crmForm.ObjectTypeCode + "&security=" + crmFormSubmit.crmFormSubmitSecurity.value + "&roleOrd=" + viewer.RoleOrder +  "&tabSet=" + viewer.TabsetId;  

viewer.IFRAME.onreadystatechange = viewer.StateChanged;  

}

else

{ viewer.IFRAME.src = "about:blank";  

}

}

viewer.StateChanged = function()  

{ if (viewer.IFRAME.readyState != 'complete')  

{ return;  

}

var iframeDoc = viewer.IFRAME.contentWindow.document;  

/* Reomve scrolling space */  

iframeDoc.body.scroll = "no";  

/* Remove crmGrid Default padding */  

iframeDoc.body.childNodes[0].rows[0].cells[0].style.padding = 0;  

/* Save MS locAssocObj */  

_locAssocObj = locAssocObj;  

/* Override MS locAssocObj */  

locAssocObj = viewer.locAssocObj;  

}  

viewer.locAssocObj = function(iType , sSubType, sAssociationName, iRoleOrdinal)  

{ /* Open the Dialog */  

_locAssocObj(iType , sSubType, sAssociationName, iRoleOrdinal);  

/* Refresh only if our iframe contains the correnct tabset name */  

if (sAssociationName == viewer.TabsetId)  

{ viewer.IFRAME.contentWindow.document.all.crmGrid.Refresh();  

}

}  

}  

function AddLogoToFormTitle(logoWidth, logoUrl)

{ var formTitleTable = null;

var tables = document.getElementsByTagName("table");

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

{ var className = tables[i].className;

if (className && className.indexOf("ms-crm-Form-Title") == 0)

{ formTitleTable = tables[i];

break;

}

}

if (formTitleTable)

{ var newCell = formTitleTable.rows[0].insertCell(2);

newCell.width = logoWidth;

newCell.vAlign = "middle";

newCell.innerHTML = '<img src="'+logoUrl+'" border="0" align="right" />';

}

}

function UnUsed()

{

 if(false)

 {

   try

   {

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Karth Profile Picture
    on at

    If you want to debug it, you can add the debugger statement in your javascript code. Ensure you enable the script debugging option on your browser settings. Its available on the Internet Options | Advanced Tab in IE.

  • Suggested answer
    Hosk Profile Picture
    on at

    The way I usually debug Javascript is to press F12 and bring up the debugger in IE.  

    This will allow you to put in a break point at the start of the onload function and then step through the javascript.  

    It will also tell you if there is a syntax error in the Javascript which could be one reason why the javascript isn't running.

    This may also help

    crmbusiness.wordpress.com/.../crm-4-debugging-javascript

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans