locked
Error Report after Javascript change RRS feed

  • Question

  • Hi All,

    I created an 'OnChange' Event that essentially pops up a message when a certain Customer is selected displaying the Contract Number for that Customer. Since creating it, whenever a Case window is closed (either with the Menu Bar 'X' or using File | Close I get an error as below:

    Microsoft Dynamics CRM Error Report Contents

    <CrmScriptErrorReport>
      <ReportVersion>1.0</ReportVersion>
      <ScriptErrorDetails>
       <Message>'crmForm' is undefined</Message>
       <Line>12</Line>
       <URL>/%7B634886299860000000%7D/WebResources/new_contractpopup</URL>
       <PageURL>/userdefined/edit.aspx?_CreateFromId=%7b2C02D3E1-0CA5-E111-93F6-000C29263A1B%7d&_CreateFromType=1&_gridType=112&etc=112&id=%7b14CDA04B-FD0B-E211-A0D6-000C29263A1B%7d&pagemode=iframe&preloadcache=1354141373324&rskey=398273665</PageURL>
       <Function></Function>
       <CallStack>
       </CallStack>
      </ScriptErrorDetails>
      <ClientInformation>
       <BrowserUserAgent>Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)</BrowserUserAgent>
       <BrowserLanguage>en-us</BrowserLanguage>
       <SystemLanguage>en-gb</SystemLanguage>
       <UserLanguage>en-gb</UserLanguage>
       <ScreenResolution>1280x800</ScreenResolution>
       <ClientName>Web</ClientName>
       <ClientTime>2012-11-28T17:22:54</ClientTime>
      </ClientInformation>
      <ServerInformation>
        <OrgLanguage>1033</OrgLanguage>
        <OrgCulture>4105</OrgCulture>
        <UserLanguage>1033</UserLanguage>
        <UserCulture>4105</UserCulture>
        <OrgID>{A77586D0-2A1F-495C-AD56-EF8968F7E822}</OrgID>
        <UserID>{AD084CF5-0B29-E211-9594-000C29263A1B}</UserID>
        <CRMVersion>5.0.9690.2243</CRMVersion>
      </ServerInformation>
    </CrmScriptErrorReport>

    I will post the Javascript below:

    var CRM_FORM_TYPE_CREATE = "1";
    var TYPE1="Customer1";
    var TYPE2="Customer2";
    var TYPE3="Customer3";
    var TYPE4="Customer4";
    var TYPE5="Customer5";
    var TYPE6="Customer6";
    var TYPE7="Customer7";
    var TYPE8="Customer8";

    // Only make these changes when the form is opened in Create mode.
    if (crmForm.FormType==CRM_FORM_TYPE_CREATE && crmForm.all.customerid.DataValue != null)
    function ContractPopup(context)
        {

        switch (crmForm.customerid.DataValue[0].name) 
    {

        case TYPE1:
              alert("CONTRACT CNR-01010 MUST BE ENTERED FOR THIS CUSTOMER");
            break;
       
        case TYPE2:
              alert("CONTRACT CNR-01009 MUST BE ENTERED FOR THIS CUSTOMER");
            break;

        case TYPE3:
              alert("CONTRACT CNR-01008 MUST BE ENTERED FOR THIS CUSTOMER");
            break;

        case TYPE4:
              alert("CONTRACT CNR-01007 MUST BE ENTERED FOR THIS CUSTOMER");
            break;
       
        case TYPE5:
              alert("CONTRACT CNR-01012 MUST BE ENTERED FOR THIS CUSTOMER");
            break;

        case TYPE6:
              alert("CONTRACT CNR-01006 MUST BE ENTERED FOR THIS CUSTOMER");
            break;
       
        case TYPE7:
              alert("CONTRACT CNR-01005 MUST BE ENTERED FOR THIS CUSTOMER");
            break;

        case TYPE8:
              alert("CONTRACT CNR-01011 MUST BE ENTERED FOR THIS CUSTOMER");
            break
        }

        }

    I am by no means a Javascript guru, so I suspect it is something I have entered wrong.


    David Robertson MCP, VCP4, AST

    Wednesday, November 28, 2012 10:30 PM

Answers

  • Hi,

    I found a little problem with you javascript, in this line is missing de "all":

    switch (crmForm.customerid.DataValue[0].name)  //Wrong

    switch (crmForm.all.customerid.DataValue[0].name) 

    But if the error continues the better way is doing debug in the client. You can put the word "debugger" in OnSave event, before that in IE press F12 and in tab "Script" press  "Start Debuging", when you close the form you will stop in word "debugger" and you can step by step found the line that is giving the error that you report.

    Hope this helps.
    If i answered your question, please mark the response as an answer and also vote as helpful.


    Pedro Azevedo Crm Specialist 4.0\2011

    Thursday, November 29, 2012 12:44 AM