Tuesday, October 16, 2007

Null is null or not an object

Have you seen this error before? Did you find a solution? I was getting this javascript error on the click of a button that had a simple rule attached to it. Everytime I clicked the button, it produced this javascript error:
Null is null or not an object.
After some debugging, I noticed that the error was occuring in the "owsbrows.js". This file contained a line that was trying to load a value from the control that was clicked in the form. The control returned "null" and hence InfoPath generated this beautiful error message.
Reason?
The postback setting of the button was set to "Never".
Solution?
Set the postback setting of the button to "Always".
1. Right click the button.
2. Select "Button Properties".
3. Select "Browser forms" tab.
4. Select "Always". Note: Selecting the default recommended option "Only when necessary for correct rendering of the form (recommended)"will not solve this problem.
When you are using rules, you  must set the postback settings of the button to "Always" so that the click event sends data to the server everytime the button is clicked.
p.s. The error occurs in browser enabled forms.

1 comment:

  1. Mate, I can't describe how happy I am to find your blog post on this topic after struggling in vain to find out why one form throws JavaScript errors after migrating to SP2010.

    Setting the control, CheckBox in this case, to Always post back fixed the problem.

    Cheers!

    ReplyDelete