Question

Have I written the below CAML query correctly? Am I missing anything? I am encountering an error on below line of code.

SPQuery spQuery = new SPQuery();
spQuery.Query = "<Where><And><Eq><FieldRef Name='Flag'/><Value Type='Text'>" + "1" + "</Value></Eq>" + "<Eq><FieldRef Name='Connection Type'/><Value Type='Text'>" + "Active Directory" + "</Value></Eq></And></Where>";

The error reads...

One or more field types are not installed properly. Go to the list settings page to delete these fields

"

Was it helpful?

Solution

The name of the columns with spaces have the space represented in Unicode as _x0020_, try the following line:

spQuery.Query = "<Where><And><Eq><FieldRef Name='Flag'/><Value Type='Text'>" + "1" + "</Value></Eq>" + "<Eq><FieldRef Name='Connection_x002_Type'/><Value Type='Text'>" + "Active Directory" + "</Value></Eq></And></Where>";

In order to get the internal name of a column:

  1. Go into List Settings or the site columns list in site settings.
  2. Click on the column you want the internal name for.
  3. Look at the URL for Field=<Column Name>

It should be at the end of the URL and will give you the exact internal name for your column.

OTHER TIPS

The <FieldRef Name='Connection Type'> is incorrect. If you used a space when creating this column then the internal name is Connection_x0020_Type

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top