This project has moved and is read-only. For the latest updates, please go here.

[Obj Error] on loading form

Feb 22, 2015 at 10:21 PM
Hi Kit,

I am using the following code in a CEWP on the child new item form.

<script src="/[Path]/jquery-1.11.0.min.js"></script>

<script src="/[Path]/sputility.min.js"></script>
<script> // url parsing from http://stackoverflow.com/a/2880929/98933 var urlParams; (window.onpopstate = function () { var match, pl = /\+/g, // Regex for replacing addition symbol with a space search = /([^&=]+)=?([^&]*)/g, decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); }, query = window.location.search.substring(1); urlParams = {}; while (match = search.exec(query)) urlParams[decode(match[1])] = decode(match[2]); })(); // wait for the window to load $(window).load(function () { try { var urlValue = urlParams['ISUCat']; SPUtility.GetSPField('ISU Category').SetValue(urlValue); } catch (ex) { alert(ex.toString()); } }); </script> When I click on the link to the new form and error message appear reading [Obj Error], once you click OK the form appears with the field pre populated but the form doesn't behave correctly, can't save it.

I am using the SPUtility file from the sites main page, and have jquery1.11.2.

any help would be appreciated.

Regards,
Feb 23, 2015 at 3:23 AM
Ok so we know the error is happening within your try/catch because you are getting the alert message. This means it is either the urlParams line or something is wrong with SPUtility.

The only thing I notice is that you say you're using jQuery 1.11.2 but your include is 1.11.0. Can you give me an example URL as well?
Feb 23, 2015 at 4:53 AM
Hi Kit,

Sorry for the confusion it is 1.11.2 we are using for jquery.

The URL calling the new form is done through javascript
<p><a onclick="javascript:NewItem2(event, &#39;[Path]/ISU/Lists/Tasks/NewForm.aspx?ISUCat=CGI&#39;); javascript:return false;" href="#" target="_self">Click to add a new Task.</a></p> I have tried it again today and for some reason the error is not appearing. Haven't changed anything from last week.

if there a way to debug for a more informative error message in case it reappears.

thanks for your assistance.

Regards,
Feb 23, 2015 at 11:24 PM
The error message is somewhat dependent on your browser but as long as you keep the try/catch in there you should be able to get more info. If the error happens again, you can use console.log with chrome or firefox to get more info.