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

SPFieldName Not Found Issue

Jan 26, 2011 at 1:50 PM

Does this work with Survey forms? I do know the code below does find the URL parameter. However, The GetSPField function cannot find my field name.

This code is at the bottom of the newform.aspx page.

<script type="text/javascript">
function GetUrlParameter(name)
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
// alert(results[1]);




Jan 26, 2011 at 5:01 PM

What type of field is IncidentID? A number field?

I haven't tried it specifically with a survey form, but I'll take a look in the next day or so and see what I can find!

Jan 26, 2011 at 5:09 PM

IncidentID is currently a single-line text field.

Jan 27, 2011 at 4:15 AM

Yup this is an issue... looks like Survey form fields are rendered differently.

I'm working on a fix and should have something uploaded this weekend.

Jan 30, 2011 at 10:45 PM
Edited Jan 30, 2011 at 10:46 PM

I've uploaded a new changeset for version 0.6 ( ) that should now support Survey forms.

Try it out and let me know if it works for you. If everything goes well, I'll promote the change to the front page.

Jan 31, 2011 at 3:10 PM

Thank you! This works. I did, however, have to use the following line to get this to work for me.

_spBodyOnLoadFunctionNames.push("setValueFromURL('MYFIELD', 'MYPARAM')");

Jan 31, 2011 at 3:53 PM

If you are putting the JavaScript in a Content Editor Web Part (CEWP) then you have a couple options with where you put it:

  1. After the survey/list form and run it immediately
  2. Before the survey/list form and...
    • Use Event.observe(window, 'load', ...)
    • Use _spBodyOnLoadFunctionNames

More information can be found on the Installation page.