SPCascadeDropdown can't find parentColumn Issue

Mar 22, 2012 at 9:03 PM
Edited Mar 22, 2012 at 9:04 PM

I am new to jQuery and java so be gentle. I have been working with the SPCascadeDropdown for a few days now and keep having the same issue. The debug keeps giving the following error.

"Error in Function

SPServices.SPCascadeDropdowns

Parameter

parentColumn: Account

Message

Column not found on page"

The Display Name of the parentColumn I am working with is "Account". No matter what I do, I can not get past this error. Here is the script I am using.

<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<script language="javascript" type="text/javascript" src="/chem/hidden/jquery-1.7.1.min.js"></script>
<script language="javascript" type="text/javascript" src="/chem/hidden/jquery.SPServices-0.7.1a.min.js"></script>
<script language="javascript" type="text/javascript">
$().SPServices.SPCascadeDropdowns({
  relationshipWebURL: "/chem/Lists",
  relationshipList: "Account Products",
  relationshipListParentColumn: "Account",
  relationshipListChildColumn: "Title",
  relationshipListSortColumn: "Title",
  parentColumn:"Account",
  childColumn: "Product 1",
  CAMLQuery: "<Eq><FieldRef Name='Status'/><Value Type='Text'>Active</Value></Eq>",
  listName: $().SPServices.SPListNameFromUrl(),
  promptText: "",
  simpleChild: true, // Added in v0.6.2
  selectSingleOption: true, // Added in v0.6.2
  matchOnId: true,     // Added in v0.7.1
  completefunc: null,
  debug: true
});</script>

 

I would really appreciate any help I can get on this.

Joe

 



Mar 22, 2012 at 10:15 PM

This error (I think) is saying that on the page from where this script is running, it can not find an input filed named 'Account'... First thing I would try is the following:

  1. Enclose your code (the call to SPCascadeDropdowns()) in jQuery's .ready() event, to insure it is executed only when the page is "ready"
  2. Include an alert that checks if the Account field is on the page.
  3. This all assumes that you are displaying fields on the page built by Sharepoint (ex. they all have a 'Title' attribute set that is equal to the visual name of the field).

 

Here is the sample code:

$(document).ready(function(){
    alert("Is Account field on the page? " + ($("[title='Account']").length > 0 ? "YES", "NO!"));
    
    $().SPServices.SPCascadeDropdowns({
      relationshipWebURL: "/chem/Lists",
      relationshipList: "Account Products",
      relationshipListParentColumn: "Account",
      relationshipListChildColumn: "Title",
      relationshipListSortColumn: "Title",
      parentColumn:"Account",
      childColumn: "Product 1",
      CAMLQuery: "<Eq><FieldRef Name='Status'/><Value Type='Text'>Active</Value></Eq>",
      listName: $().SPServices.SPListNameFromUrl(),
      promptText: "",
      simpleChild: true, // Added in v0.6.2
      selectSingleOption: true, // Added in v0.6.2
      matchOnId: true,     // Added in v0.7.1
      completefunc: null,
      debug: true
    });
});

Paul

Mar 22, 2012 at 10:52 PM
Edited Mar 23, 2012 at 8:28 PM
Paul,
 
First, Thanks so much for responding so quickly! I tried what you had suggested and it seems to have taken care of the error. My latest issue is that the childColumn dropdown has only one choice "None". The parentColumn allows me to choose the Account as desired but only "None" for the childColumn. Any thoughts on this one?
 
Thanks again for you help!
 
Joe
Coordinator
Mar 23, 2012 at 1:51 PM

Odds are that's a data issue. You're filtering for Status='Active'. Are there active items in the relationshipList?

M.

Mar 23, 2012 at 8:39 PM

Marc,

Thanks for all you have done here and thanks for the help! You were right. I removed that filter and that issue is gone but now there is another. If I understand the function correctly, the script should filter by the selected parent value right away so that when I go to the child drop down, I should only see the child values from items that have the selected parent value. The child dropdown shows all values from all items. I really do apreciate you guys helping a "noob" out.

Coordinator
Mar 23, 2012 at 10:30 PM

Next I'd look at how you have your lists set up. You're expecting the right behavior.

BTW, you're specifying all of the options, which you don't need to do. The docs indicate which are required and what each one does.

M.

Mar 26, 2012 at 2:39 PM

Marc,

My lists are setup like the examples with the exception that it is possible for the child column to return multiple like values. In the grand scheme of things, I had planed on filtering further. I am just trying to get the first set working before I move on to the next set of drop downs.

About the docs....Remember that I said I was a "noob". When you say I don't need to specify all the options....Is that to say I do not need to include the line of code if I do not want the option? Also, could you recomend an on line class for people like me?

As usual thank again!

Joe

Mar 26, 2012 at 5:08 PM

I figured it out! My problem was that I had spaces before each line of code for indents instead of tabs. I suppose that would be covered under Java Script 101. Lesson learned!

Thank you to Marc and Paul for helping me out!

Coordinator
Mar 26, 2012 at 5:11 PM

Spaces are actually fine, so it must have been something else.

What I mean about specifying all of the options was that you only need to specify the options which are requred (like relationshipList) or where you want to override the defaults.

M.

Mar 26, 2012 at 7:33 PM

I know in the demo for the SPCascadingDropdowns that there are three lists used, Region, State & City. So there are three different lists and two different relationship lists. My question is now is it possible to do the three cascade dropdown scenario with only two lists and one relationship list? 

 

Joe

Coordinator
Mar 26, 2012 at 8:35 PM

Joe:

Yes, you call the function once per relationship. You can have 1-n of them.

M.

Mar 26, 2012 at 9:27 PM

Marc,

I understand and it kind of worked. The result looks like it filtered by Account instead of Product. My dropdown shows 3 "Cooling" choices. The Account Products list has 3 entries for the specified Account with "Cooling" selected in the "Category" column. There is only one entry on the list for the specified Account and the specified Product with "Cooling" selected in the "Category" column. Here is the script I used.

$(document).ready(function(){
	$().SPServices.SPCascadeDropdowns({
		relationshipWebURL: "",
		relationshipList: "Account Products",
		relationshipListParentColumn: "Account",
		relationshipListChildColumn: "Title",
		relationshipListSortColumn: "",
		parentColumn:"Account",
		childColumn: "Product 1",
		CAMLQuery: "",
		listName: $().SPServices.SPListNameFromUrl(),
		promptText: "",
		simpleChild: true, // Added in v0.6.2
		selectSingleOption: true, // Added in v0.6.2
		matchOnId: false,     // Added in v0.7.1
		completefunc: null,
		debug: true
	});
	$().SPServices.SPCascadeDropdowns({
		relationshipWebURL: "",
		relationshipList: "Account Products",
		relationshipListParentColumn: "Title",
		relationshipListChildColumn: "Category",
		relationshipListSortColumn: "",
		parentColumn:"Product 1",
		childColumn: "Category 1",
		CAMLQuery: "",
		listName: $().SPServices.SPListNameFromUrl(),
		promptText: "",
		simpleChild: true, // Added in v0.6.2
		selectSingleOption: true, // Added in v0.6.2
		matchOnId: false,     // Added in v0.7.1
		completefunc: null,
		debug: true
	});

Coordinator
Mar 26, 2012 at 9:49 PM

You're using the same relationshipList for the two relationships, so you can't be following the rules. Take a look at the Country / Regions / State example I give in the docs again. Each relationship should be contained in its own list to ensure that you're following good relational table rules.

M.

Jan 30, 2014 at 9:57 AM
I have had the same problem when we migrated from 2007 to 2010.

The problem was that the Parentcolumn was not found on the page, but I could clearly see it.
My dropdown box was a "required" one and I had to rename the Parentcolumn from "Project number" to "Project number Required Field".

On the page the name is still Project number, but it only worked when I added the "Required Field" addition to the name.

Hope this helps someone...

pMzQ,
Coordinator
Jan 30, 2014 at 12:08 PM
pMzQ:

Do you mean migrated from 2007 to 2013 on Office365?

M.
Coordinator
Feb 4, 2014 at 3:12 PM
Can any of you try the latest alpha?
https://spservices.codeplex.com/releases/view/116626

It's got a fix for the Office365 " Required Field" issue. If anyone here has seen this issue in the wild with SharePoint 2010 and can post the markup, I'd appreciate it.

M.
Mar 14, 2015 at 12:03 AM
Hey, I had this issue with one of my NewItem forms. I read all sort of different post on it and literally wasted a whole day of work to fix it.

First thing that I had to do to find the infamous column-that-could-not-be-found was delete the form field element from the form (the supervisor dropdown box in my case). Get rid of the description in the code as well.

Secondly, I had to create a new NewItem form that I could make sure worked, even before adding the dropdown cascade function. I literally tried to copy and replicate everything that was on that new form unto the old form to no avail, until I decided to copy the SHAREPOINT:FORMFIELD element from the new form code only and voila! The darn thing worked. I almost had a heart attack, but I wouldn't have been able to take it this far without yall's input. Appreciate it!