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

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Uncaught TypeError: Cannot read property 'length' of undefined

(0) ShareShare
ReportReport
Posted on by

Hi,

on the Contact Form, I sometimes get the following error when leaving/reloading it:

Microsoft Dynamics CRM Error Report Contents

<CrmScriptErrorReport>
  <ReportVersion>1.0</ReportVersion>
  <ScriptErrorDetails>
   <Message>Uncaught TypeError: Cannot read property 'length' of undefined</Message>
   <Line>1</Line>
   <URL>/_static/_common/scripts/jquery1.7.2.min.js?ver=-385083350</URL>
   <PageURL>/main.aspx?etc=2&extraqs=%3f_gridType%3d2%26etc%3d2%26id%3d%257b3E8A660C-180C-E411-80DF-005056BE4542%257d%26rskey%3d%257b00000000-0000-0000-00AA-000010001003%257d&pagemode=iframe&pagetype=entityrecord&rskey=%7b00000000-0000-0000-00AA-000010001003%7d</PageURL>
   <Function>anonymousr:Cannotreadproperty'length'ofundefined</Function>
   <CallStack>
    <Function>anonymousr:Cannotreadproperty'length'ofundefined</Function>
   </CallStack>
  </ScriptErrorDetails>
  <ClientInformation>
   <BrowserUserAgent>Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36</BrowserUserAgent>
   <BrowserLanguage>undefined</BrowserLanguage>
   <SystemLanguage>undefined</SystemLanguage>
   <UserLanguage>undefined</UserLanguage>
   <ScreenResolution>1920x1200</ScreenResolution>
   <ClientName>Web</ClientName>
   <ClientTime>2014-12-12T08:18:11</ClientTime>
  </ClientInformation>
  <ServerInformation>
    <OrgLanguage>1033</OrgLanguage>
    <OrgCulture>1033</OrgCulture>
    <UserLanguage>1033</UserLanguage>
    <UserCulture>1033</UserCulture>
    <OrgID>{B7D590B3-C8AE-E311-80BD-005056BE2160}</OrgID>
    <UserID>{3F12AE6B-3FAF-E311-80BD-005056BE2160}</UserID>
    <CRMVersion>6.1.1.132</CRMVersion>
  </ServerInformation>
</CrmScriptErrorReport>

This happens quite a lot to me. Is this a CRM bug or is some of my custom code causing a problem here?

Best regards

Michael

*This post is locked for comments

I have the same question (0)
  • Royal King Profile Picture
    27,686 on at
    RE: Uncaught TypeError: Cannot read property 'length' of undefined

    Are you using jquery in your web resource file? if so it might be from script

  • Community Member Profile Picture
    on at
    RE: Uncaught TypeError: Cannot read property 'length' of undefined

    Hi Chitra,

    yes, I am using jquery 2.1.1 wrapped in my own namespace to avoid conflicts with the CRMs jquery in the following way:

    var isConflictedEnvironment = typeof $ !== 'undefined';
    
    if (isConflictedEnvironment)
    {
    	Type.registerNamespace('tv');
    }
    
    // jquery 2.1.1 source code
    
    if (isConflictedEnvironment)
    {
    	tv.$ = jQuery.noConflict(true);
    }

    So my jQuery instance lives within the "tv" namespace and should not conflict with the global $ alias used by the CRM. Do you think that's causing the error within jquery 1.7.2 used by the CRM?

    Regards

    Michael

  • Royal King Profile Picture
    27,686 on at
    RE: Uncaught TypeError: Cannot read property 'length' of undefined

    the error is not in jquery. Some where in your script you are trying to get length of the object  using jquery or trying apply some operation but object is null.  check null value before applying any operation on the object in your script

  • Suggested answer
    Hosk Profile Picture
    on at
    RE: Uncaught TypeError: Cannot read property 'length' of undefined

    Check your Javascript code where you are using length e.g. field.length.

    The error is saying that the variable is null and you can't get the length of a null variable.

    You need to do a null check before using the length value

  • ScottDurow Profile Picture
    21 on at
    RE: Uncaught TypeError: Cannot read property 'length' of undefined

    It is possible that your jquery registration is causing the issue - but the simplest way will be remove this JavaScript and see if it no longer happens!

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Uncaught TypeError: Cannot read property 'length' of undefined

    So, by accident I stumbled over the real culprit here: I am also using jQuery UI 1.11.2 in some of my scripts which is designed to work with jQuery 2. Sometimes, jQuery UI was loaded before my jQuery instance was initialized in tv.$ and then UI just used jQuery 1.7.2 provided by the CRM. This caused some error inside the CRMs jQuery 1.7.2, which led me to assume this is a bug within the CRM, but it was actually caused by jQuery UI.

    I guess this is because the CRM loads JS Webresources asynchronously?

    I now enhanced my jQuery wrapper a check if my jQuery instance has been loaded yet (inspired by Scott's blog entry here, thanks btw. Your blog has been of great help to me :) ).

    Thanks your help, guys!

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
UllrSki Profile Picture

UllrSki 2

#3
SC-08081331-0 Profile Picture

SC-08081331-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans