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

SP 2010 Custom List Forms

Jul 13, 2011 at 10:47 AM

Hi

Has anyone had any luck with getting SPUtility to work with 2010 Custom List Forms.  I have been trying to get a NewForm.aspx with pre-populated fields from a URL.  I have put a CEWP below the form with the following code:

<script src="/Testing/JS/prototype.js" type="text/javascript"></script>

<script src="/Testing/JS/SPUtility.js" type="text/javascript"></script>

<script type="text/javascript">

 function GetValueFromURL(queryParamName) {
    var queryParams = location.href.toQueryParams();
    if (queryParams != null && queryParams[queryParamName] != null) {
        return decodeURI(queryParams[queryParamName]);
    }
    return null;
}

Event.observe(window,'load',function(){
    try {
      var urlValue = GetValueFromURL('String');

alert(urlValue);

var field = SPUtility.GetSPField('Summary');
 
alert(field);

field.SetValue(urlValue);

 } catch (ex) {
      alert(ex.toString());
    }
});</script>

The alerts are in there just for debugging purposes. 

This code works fine when using the default Sharepoint List form, but when i create a custom form with Infopath it comes back with Null as the SPField name.

This is on a Sharepoint Ent Server, using SPUtility 0.8, and it is a Custom SP List.

Any thoughts would be much appreciated

Thanks

Gareth

Coordinator
Jul 13, 2011 at 6:55 PM

Hmm.. interesting. I don't have 2010 at the moment but I could take a guess at what is happening (assuming you did something like is outlined here).

Part of what SPUtility.js does is finds the controls on the page when you call GetSPField. Unfortunately, this largely depends on the page's HTML being consistent. I'm guessing that when Infopath is used to customize the list form, it changes the pages HTML structure and layout of controls.

I logged a new issue but no ETA at the moment.