This project has moved. For the latest updates, please go here.

"Unable to get a SPField named x" error

Feb 16, 2016 at 10:15 AM

Have managed to use Kit's precursor to SPUtility to inject a value into a text field and make it read only, based on a URL parameter.

I now want to inject values into a date field and a dropdown box, so am using SPUtility.

I am however coming with an error when the form loads, saying "Unable to get a SPField named x" (where X is what I've put in the code as the field name).

I've tried both the field internal name (when looking in the list settings for that field (edit the field, then look at the URL)) and the display name as shown on the newform.aspx page, but both give me the error.

Any ideas what I'm doing wrong please?
I'm referencing jQuery (using 1.3.2) and sputility

I'm asusming MDS is turned off, as the precursor worked fine for the text only field edit.
Feb 23, 2016 at 3:41 PM
Edited Feb 23, 2016 at 3:42 PM
Hey mtngeekuk,
A few questions:
  1. What version of SharePoint are you using? [SharePoint 2007, SharePoint 2010, SharePoint 2013, or SharePoint online / office 365]
  2. What type of list? [Document Library, Custom List, Calendar, etc.]
  3. Have you customized the form with SharePoint designer? If so, SPUtility won't work.
  4. You mentioned MDS... an easy way to tell is if you go to Site Settings -> Manage Site Features and see if Minimal Download Strategy is enabled. Do you see it enabled? If so, SPUtility.js won't work.
Feb 23, 2016 at 4:29 PM
Hi Kit
  1. SharePoint 2013 Enterprise on-premise
  2. The list is a survey. I want to prepopulate the options for a training review survey, based on a training record from another system (e.g. name of system / training session, date of training etc.)
  3. Have been editing the aspx page using the trick in the precursor instructions (change the URL, then insert content editor we part with the script)
  4. No MDS
Thanks in advance...
Feb 24, 2016 at 1:26 PM
Thanks for the answers. I am able reproduce this issue with surveys in 2013 so this is definitely a bug with SPUtility.js. I created issue #19 already but I'm hoping to take a look at it soon now that I have some more time.
Feb 24, 2016 at 1:54 PM
Hi Kit,

Many thanks - glad it's not just me!

If you need anything more from me with regard to this, just let me know.


Feb 29, 2016 at 2:37 AM
I fixed the problem with surveys in v0.12.0. Could you take a look and see if it works for you?
Mar 1, 2016 at 8:35 AM
Hi Kit,

This now works perfectly! Thank you so much.

I'm having another slightly different issue and not sure if it's related...

The code below is in the content editor on the newform.aspx page.

If I use a URL parameter (e.g. http://path-to-survey/NewForm.aspx?SessionTitle=BLAH) for a single parameter, it does exactly what it is supposed to do.
Conversely, if someone just opens the form (which is possible) (e.g. http://path-to-survey/NewForm.aspx), this also works fine (i.e. no values automatically populated, or any fields marked as read only)

What I want to be able to do is have three parameters in the URL (e.g. http://path-to-survey/NewForm.aspx?SessionTitle=BLAH&SessionLocation=BLAH&SessionDate=BLAH) which would fill in those values and make them read only if using the URL like this, but not touch the fields if using the straight http://path-to-survey/NewForm.aspx

Could you advise on what I'm doing wrong please?

// url parsing from
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 =;
// fix for sharepoint 2013 URLs which use the hash
if (query === '') {
query = window.location.hash.substring(window.location.hash.indexOf('?'));
query = query.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['SessionTitle'];
SPUtility.GetSPField('Title of Training Session').SetValue(urlValue).MakeReadOnly();
} catch (ex) {