Error in CAML query
-
09-12-2020 - |
Pergunta
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
"
Solução
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:
- Go into List Settings or the site columns list in site settings.
- Click on the column you want the internal name for.
- 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.
Outras dicas
The <FieldRef Name='Connection Type'>
is incorrect. If you used a space when creating this column then the internal name is Connection_x0020_Type
Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange