Exception occurred in the client script. Cannot read property 'length' of undefined

Exception occurred in the client script. Cannot read property 'length' of undefined

  

Hi, 

I seem to be getting this error when running a particular action for the first time. However, from running the debugger, the action does get all the way to the end.

Has anyone had a similar problem or is able to suggest anything to help?

Thanks!


Hi Yassar,

You are trying to access a element through javascript which is not loaded yet. Check in your page, how many elements from your page you are trying to use in javascript code and check if they are available on your page in browser i.e. somelement.id

Thanks and Regards,

Suraj Borade

It seems that the javascript code is running before the object is rendered on the screen.

You are getting the length of the object before the object is available.

It's been a while since this was posted but in case someone runs into this thread like I did... 

For me, this error occurred if there was a CharacterCount widget associated to an input field with Enabled = False. An error also occurs if you associate a PopupEditor to a disabled Link. This is why I looked for disabled items when I got the 'cannot read length' error.

I'm learning that it's not a good idea to associate widgets to other widgets that I may set to be disabled (Enabled = False).

For links, my work around was to wrap the Link in an <If> that checks for the condition that should disable the link. The Link with its associated PopupEditor widget goes in the True part. A copy of the Link (with Enabled = False and no PopupEditor) goes in the False part. Unfortunately, this solution gives a Duplicate Bind error if you try to use it with Input Fields and CharacterCount widgets. You could replace the Input Field with an Expression and accept the styling difference or figure out the CSS styling so it looks like an Input Field that is disabled.