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

Problems getting it to work...

Nov 23, 2009 at 10:14 AM



I've added some code to one of my NewItem pages from SD:

<asp:Content ContentPlaceHolderId="PlaceHolderPageTitleInTitleArea" runat="server">
 <SharePoint:ListProperty Property="LinkTitle" runat="server" id="ID_LinkTitle"/>:
 <SharePoint:ListItemProperty id="ID_ItemProperty" MaxLength=40 runat="server"/>

    <script type="text/javascript" language="javascript" src="/js/jquery-1.3.2.js"></script>
    <script type="text/javascript" language="javascript" src="/js/jquery.SPServices-0.4.5.js"></script>

    <script type="text/javascript">
       $(document).ready(function() {
         debug: true;
         var thisSite = $().SPServices.SPGetCurrentSite();



no debug-info comes up, and nothing happens - any suggestions? 

Nov 23, 2009 at 12:42 PM


The script as you show it will actually throw an error.  (Be sure to watch for the little yellow error icon in the bottom right of the Internet Explorer browser window.  If you see it and double click it, you *sometimes* get some useful information.)

First thing to check is that your references to the two jQuery libraries are correct.  The debug option only makes sense in the context of one of the SPServices functions which currently support it.  The debug: true; line isn't valid JavaScript. Instead, add the line alert("Hello jkdevela!"); in its place. If your library references are correct, you'll get the alert popup.  If not, check 'em.

All that the var thisSite = $().SPServices.SPGetCurrentSite(); line is going to do is set the thisSite var to the string URL for the site.  What are you trying to do?


Nov 23, 2009 at 12:52 PM


First - one line in the code is missing - I had an alert showing thisSite. Just to check if anything is working. I tested some other functions first without any results...

I dont get any error messageses (error icons) in IE. And if I paste the url for the scripts I get the usual download dialog, så the reference to the .js files is correct...

Nov 23, 2009 at 2:36 PM

If your alert isn't firing, then you probably just have the scripting in the wrong place in the page.  I generally put my scripts just below:

<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">

This placeholder is always loaded, so it ensures that the scripts will run.


Nov 24, 2009 at 8:55 AM


I have now moved my scripts, and now I get data from a related list.

But, this is what I need:

I have a custom list with the fields ProjectNo, ProjectName, ProjectLeader, ProjectLeaderPhone, ProjectStart,....

I've created a copy of the NewForm called NewForm2 and added references to the scripts.

The user should type in the ProjectNo value in the ProjectNo textbox. When the user leaves the ProjectNo textbox I want to get the ProjectName and ProjectLeader to the textboxes from a webservice "http://iisserver/agri/ws.asmx?op=getProjectsByProjectNo". I havent fugured out how to do this.

And for a better solution: while the user types the projectNo in the textbox it would have been nice to show a list of projects matching allowing the user to click an item in the list to select - and update the ProjectName and ProjectLeader textboxes....


Nov 24, 2009 at 2:06 PM

Sure, all possible.  It looks like you have a custom Web Service, which my library will know nothing about, of course.  However, you should be able to use the code in the library as a quide to how you might get it to work. If you look at the $().SPServices.SPDisplayRelatedInfo code, it should give you a decent starting point.


Nov 25, 2009 at 11:33 AM


Thank you for your help.

An aditional question... SPDisplayRelatedInfo only displays one result item. Is it possible to make it display several?


Nov 25, 2009 at 12:42 PM

It actually ought to show all of the matching items. Let me know if it doesn't and I'll look to see if a bug has crept in there.


Nov 25, 2009 at 5:43 PM


Maybe something with the list...

I have a projects-list with projectNo and projectName. Items in the list with projectNo = 1, 11, 12, 2, 21, 22....

When I type in 1 in the NewForms projectNumber I want to see all projects with projectNo starting with 1 (1, 11, 12)...

Nov 25, 2009 at 8:41 PM

OK, well starting with 1 isn't a match by the SPDisplayRelatedInfo function.  It's looking for exact matches.  You could clone it and make your own version that does starts-with matches.


Nov 30, 2009 at 2:24 AM

See my blog post here:

I think that I will add an option for "starts-with" logic to SPDisplayRelatedInfo in the next release. Stay tuned.


Nov 30, 2009 at 2:26 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Dec 2, 2009 at 4:06 AM


I've got the functionality that you were looking for in 0.4.7ALPHA1, I think.  Give it a whirl and let me know if it works the way you want it to:

Here's a blog post about it:


Dec 2, 2009 at 7:41 AM


I'll have a look at it soon.

Now I'm struggling with some other cases... :-(

I have a .Net web-service on another server that I want to pull out some xml-data to the NewForm based on user input. I thought that would be easy, but... I'll appreciate any tip :-)


May you give me some hints how to make a "selection-list" from the list made from SPDisplayRelatedInfo? When the user types and gets a list of values "begins with" it would be nice to let the user select from the resulting list...


Dec 2, 2009 at 12:47 PM

If you look through the code for SPDisplayRelatedInfo, you'll see how it works and perhaps that will help with the other Web Service.  I'm happy to try to look at your jQuery if it would be helpful.  The basic idea would be to build up the SOAP wrapper as I do in the library, and then call the jQuery ajax function.  Take a look at lines 512-524 in jquery.SPServices-0.4.7ALPHA1.js to see how the ajax function is used.  You probably will want to refer to the jQuery documentation for other options.

Making a "selection-list" was another option I thought of yesterday.  Let me take a crack at that soon, and I'll let you know when there's something to test.