SPFilterDropdown: columnName: column not found on page

May 16, 2011 at 10:29 AM

Hello,

I'm trying to use the new SPFilterDropdown function to set up a filtered lookup column.

However, for some reason, the script keeps giving me an error about the column name:

Error in function
SPServices.SPFilterDropdown
Parameter
columnName: Test2
Message
Column not found on page

Click to continue

 I'm running WSS 3.0 in French. Like it's said in the documentation, I created a NewFormCustom.aspx and updated the link in my list properties using Sharepoint Designer. Here is the code I inserted in the PlaceHolderMain block:

<script language="javascript" type="text/javascript" src="/Divers/jquery-1.5.2.min.js"></script>
<script language="javascript" type="text/javascript" src="/Divers/jquery.SPServices-0.6.1.min.js"></script>
 
<script language="javascript" type="text/javascript">
$().SPServices.SPFilterDropdown({
  relationshipList: "Interventions",
  relationshipListColumn: "Title",
  columnName: "Test2",
  CAMLQuery: "<Eq><FieldRef Name='Machines' /><Value Type='Text'>IBM</Value></Eq>",
  completefunc: null,
  debug: true
});
</script>

The list "Pointage" contains a lookup field "Test2" that fetches the field "Title" from the "Interventions" list (located in the same web).
I'd like to filter out all items from "Interventions" whose "Machines" field is not equal to "IBM".
 
Could anyone help me ? I can't figure out what I did wrong.
Regards,
Sébastien. 
Coordinator
May 16, 2011 at 7:11 PM
Edited Dec 2, 2013 at 3:50 PM
Sébastien: The error is telling you that there is no column in the page (NewFormCustom.aspx) which has a DisplayName of Test2. The function looks for the DisplayName in the page, and it doesn't seem to be finding it. It's possible that the fact you're using a French language site is causing a problem. I can't test with every language pack, of course, but I do try to deal with issues as they arise. (See my article Variations in Multiselect Controls in Different SharePoint Language Versions.) Can you post the source code for the Test2 column from the browser (View Source, and cupy out the relevant part)? M.
May 19, 2011 at 8:54 AM

Hello sympmarc, and thanks for the reply.
Here is the source code for the Test2 column (note that test2 is not a MultiSelect control):


<TR> <TD nowrap="true" valign="top" width="190px" class="ms-formlabel"><H3 class="ms-standardheader"> <nobr>Test2</nobr> </H3></TD> <TD valign="top" class="ms-formbody" width="400px"> <!-- FieldName="Test2" FieldInternalName="Test2" FieldType="SPFieldLookup" --> <span dir="none"><select name="ctl00$m$g_ae49946f_1eef_4f97_b417_1c0bc9ba81a9$ctl00$ctl04$ctl06$ctl00$ctl00$ctl04$ctl00$Lookup" id="ctl00_m_g_ae49946f_1eef_4f97_b417_1c0bc9ba81a9_ctl00_ctl04_ctl06_ctl00_ctl00_ctl04_ctl00_Lookup" title="Test2"> <option value="0">(Aucune)</option> <option value="806">Application cylindre fig&#233;e</option> <option value="816">APT &amp; APTQ bloqu&#233; sur 2 jours</option> <option value="800">VT220 Fin de Ligne Out</option> </select><br/></span> </TD> </TR>

Coordinator
May 19, 2011 at 10:17 PM

Sébastien:

Hmm. This ought to work just fine. SPFilterDropdown is looking for a select with the title="Test2", and it clearly ought to find it. There's nothing "French" about the markup that I can see.

The one thing I notice is that you don't have the call wrapped in $(document).ready(), so the call may be happening before the select is in the DOM. Try this:

<script language="javascript" type="text/javascript">
$(document).ready(function() {
  $().SPServices.SPFilterDropdown({
    relationshipList: "Interventions",
    relationshipListColumn: "Title",
    columnName: "Test2",
    CAMLQuery: "<Eq><FieldRef Name='Machines' /><Value Type='Text'>IBM</Value></Eq>",
    completefunc: null,
    debug: true
  });
});
</script>

M.

May 20, 2011 at 11:22 AM

Marc,

 

Thanks a lot for your tip, now I don't get the error anymore !

However, the filter still doesn't work. I'm trying to filter on a choice column.

When I enter a random column value, all items are filtered out (normal) but when I put a value that exists among the choices, none are filtered (they all appear in the dropdown list).

The script:

$(document).ready(function() {
  $().SPServices.SPFilterDropdown({
    relationshipList: "Interventions",
    relationshipListColumn: "Title",
    columnName: "Test2",
    CAMLQuery: "<Eq><FieldRef Name='Machines' /><Value Type='Choice'>ETUCHE</Value></Eq>",
    completefunc: null,
    debug: true
  });
});

Coordinator
May 20, 2011 at 6:56 PM

Sébastien:

Great! One step forward.

Does the Choice column that you are attempting to filter on allow only one selection or is it multi-select?

M.

May 20, 2011 at 8:25 PM

It only allows one selection.

May 31, 2011 at 4:53 PM

Any idea ? This is such a strange problem...

May 31, 2011 at 5:52 PM

I have had luck using the contains option in the CAML query for choice fields <Contains><FieldRef Name='Machines' /><Value Type='Text'>ETUCHE</Value></Contains>

Dan

Coordinator
May 31, 2011 at 5:54 PM

Is the column in the form that you want to filter Test2 a Lookup column to the Title column in the Interventions list?

M.

May 31, 2011 at 7:23 PM

sympmarc: Yes, Test2 is a lookup column to the Title column in the Interventions list.

spevilgenius: I've jsut tried with "Contains" and the same thing happens: I get either all items (if for example I try to filter on 'Machines' containing 'ETUCHE') or none (if I enter a value that is not in the list).

 

Coordinator
May 31, 2011 at 7:42 PM

I just tried this and it worked for me. My list SimpleSelect has a column called Country, which is a Lookup into the column called Title in the Countries list. In the Countries list, I created a column called CountryType, which is a Choice column with the values [A, B, C]

   $().SPServices.SPFilterDropdown({
    relationshipList: "Countries",
    relationshipListColumn: "Title",
    columnName: "Country",
    CAMLQuery: "<Eq><FieldRef Name='CountryType' /><Value Type='Choice'>A</Value></Eq>",
    completefunc: null,
    debug: true
   });

Using the above code, I only get United States, which is the only country with CountryType set to A. When I set CountryType to A for Trinidad & Tobago, it then shows up as well.

I wonder what could be different?

M.

Jun 2, 2011 at 11:19 PM

I eventually found out what was causing the problem and you should be able to reproduce it:

If in your Countries list you add an entry with an empty title (it's required to untick the mandatory property of the title column first) and CountryType=A, then try to add an entry in SimpleSelect, you will notice the dropdown list will be empty.

I filled the empty fields with some values and now it works :).

Anyways, thanks for the help, this plugin and forum rock !

Coordinator
Jun 3, 2011 at 4:13 AM
Glad you got it working. I think it's reasonable for us to assume that there will always be a Title in a reference list like this, yes? Making it not required shouldn't happen.

M.
>
Jun 3, 2011 at 4:05 PM

Yes indeed. However, one could maybe be willing to use another relationshipListColumn than Title where empty values are a possibility, in which case the script doesn't really behave as expected (imo).

This is not a big problem, but I just wanted to report it in case someone else ever experience the same thing.

Jun 3, 2011 at 8:13 PM

What examples can you give to have a relationship list that has blank values?