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

use SPServices and jQuery on Document Library New/Upload form

Nov 2, 2011 at 9:58 PM

I am trying to figure out how to use you SPServices lib and the jQuery lib only within the upload form for a document library in SP2010.  Basically, I have 2 columns that are dropdowns and I want to cascade them.
I understand how I would do this on a brand new/custom page, but if I need to edit the OOB document library form, is that something I can do in order to add the required JS?

Nov 2, 2011 at 11:57 PM

You wouldn't change the upload page, but EditForm, right? You can either add a CEWP for the script or edit a *copy* of the form. There are details at the bottom of the main documentation page.

Nov 3, 2011 at 9:17 PM

Actually, I need to change both.  I can do the EditForm from the web interface using the ribbon command Form Web Parts > Default Edit Form.  However, my document library has a single default content type (for the New... button) which inherits from Folder.  In other words, the users are creating new specialized folders that have metadata.  When you click the new button, the Upload.aspx form is used.  I guess for that, I have to use SPD to add the JS, correct?

On a different note, I made the changes to the EditForm using a CEWP, and I am getting a JS error from the SPService as follows:

Error in function
relationshipListParentColumn: MatterType or relationshipListChildColumn: Title
Not found in relationshipList MatterSubType

Here are details on my setup:

I have a List named MatterType, and a list named MatterSubType.
MatterSubType list has 2 columns:

  • Title - static name
  • MatterType (lookup to list MatterType) - static name

My document library has 2 lookup value columns used in the form as dropdown lists:

  • Matter Type (display name)
  • Matter SubType (display name)

Here's my JS code:

$(document).ready(function() {
		relationshipList: "MatterSubType",
		relationshipListParentColumn: "MatterType",
		relationshipListChildColumn: "Title",
		parentColumn: "Matter Type",
		childColumn: "Matter SubType",
		debug: true

 Any ideas what the problem might be with the JS above?


Nov 3, 2011 at 9:38 PM

Ok...I figured out.

The "relationshipList" parameter expects the "display name" not the internal name of the list.  I created the list initially without spaces in the name, so I can get a pretty URL, then I edited the list name to add the space for readability.  SPServices expects the display name of the list, not the internal name, which is created when the list is first created and is never changed.

Cascading dropdowns now work like a charm! Thanks for a great library!

Nov 3, 2011 at 9:43 PM

Excellent! Glad you got it working.