Exception while executing CAML query sharepoint 2007 - sharepoint

Name of the column in document library is :
Column name => Keywords (Sub-Processes, Methodology, Servicing Model, etc)
Column Type=> Multiple lines of text
We are using the above column name in the caml query as below
query.Query = "<Where><Eq><FieldRef Name='Keywords(Sub-Processes,Methodology,Servicing Model, etc)'/><Value Type='Text'>Merchant Services,Merchant Set Up</Value></Eq></Where>";
but when we run the code we get the exception:
Microsoft.SharePoint.SPException: One or more field types are not
installed properly. Go to the list settings page to delete these
fields.
Is this exception because of special characters used in the column name if yes then how can I correct it.
We can't change the column name because it is requirement.

Internal names and display names are quite different from each other. They can be the same in some cases but not all. There is generally an escape sequence in between two words with a space.
It is often a good practice to retrieve the internal name at runtime rather than hardcoding it.
Here's how to do it:
var internalName=list.Fields.GetFieldByInternalName(column.ColumnName).Title;

I can tell you for sure (given the special characters) that that's not the internal name of the field. It might be the display name, but it's not the internal name.
The error is because there is no field with an internal name of what you have provided.
Personally, when I want to find the internal name of a field I go to the list settings for the list and edit the column. When doing so there will be a query parameter with 'field=' followed by the internal name. There are other places that it can be found, and other sharepoint tools (SharePoint Manager was mentioned by another poster) that can be used to get such information.

I used "Keywords_x0020_x002f_x0020_Folksnomy" and it worked for me.
I fetched all the columns of the Document library and bind it to the GridView,in GridView I found this name.
Display Column name => Keywords (Sub-Processes, Methodology, Servicing Model, etc)
Wrong one is =>
Keywords_x0020_(Sub-Processes,_x0020_Methodology,_x0020_Servicing_x0020_Model,_x0020_etc)
Newly found correct name is => Keywords_x0020_x002f_x0020_Folksnomy

Related

Kentico 12 Azure Search

I'm trying to implement Azure Search on Kentico 12. Following the article below.
https://docs.kentico.com/k12/configuring-kentico/setting-up-search-on-your-website/using-azure-search/integrating-azure-search-into-pages
However, I have multiple indexes defined on the smart search not just a single index code name that I can hard code and also cannot aford to hard code index fields. Is there any tutorial out there that I can follow?
It sounds as if you're referring to building an Azure Search web part, is this correct. If so, make a property in your web part which allows you to select the code name from a list in the database. Secondly, regarding field names, you should be using generic field names like DocumentName, NodeAliaspath, etc. Although if you have very specific search results that need to be displayed, simply put in a switch statement to get the field names based on a class name.

Smart search results behaviour of compound index of multiple page types

Can someone confirm the behaviour of the Smart search results webpart when using a Smart search filter on a particular field, documentation here, when the index, and the expected results, are compound of multiple page types?
In my scenario I have 2 page types, one is always a child of the other, my hypothetical scenario would be a Folder and File types as an example.
I've configured the index with Pages type and Standard analyzer to include all Folder and File types under the path /MyOS/% on the tree.
The search page, includes the Smart search results webpart and a Smart search filter, a checkbox for the File's field FileIsHidden.
What I'm trying to ascertain is the possibility for the results to include all folders that have a hidden field, as well as the files?
Client has a v8.2 license and now has a requirement similar to this scenario.
Thanks so much for any help in advance.
Firstly what i would do is download the latest version of LUKE, it's a lucene inspector that allows you to run queries, inspect the data, etc.
https://code.google.com/archive/p/luke/downloads
Your search indexes are in the App_Data/Modules/SmartSearch/[SearchName], now i am not sure if LUKE can query 2 indexes as the same time, however you can run hte same query against both and see if it's filtering out results one way or another.
If you are trying to query where a field must be a value, and the other page type does not have the field, it probably is filtered out. What you need to do is use the lucene syntax to say "(classname = 'cms.file' and fileonlyproperty = '' OR classname <> 'cms.file')" so to say.
You'll have to test, but say the class name is cms.file and cms.folder, and the property is FileIsHidden, i think the syntax would be:
+((FieldIsHidden:(true) and classname:('cms.file')) OR (NOT classname:('cms.file'))
But you'll have to test that.

How to use the content search web part to filter on a custom user profile property

We added the department number from AD to sharepoint. This property is multi valued in AD, and its multivalue in sharepoint.
My user profile screenshot:
http://screencast.com/t/e9xaZMyJJ2
Then in the CSWP, I want to filter by this value, please check here:
http://screencast.com/t/rlP95vrYRB3E
If I check the TEST, its using a GUID instead of the 613 code
http://screencast.com/t/ASltLUsIP
I am totally clueless.!! any idea?
Mapped property screenshot here:
http://screencast.com/t/gLXs2ZIR
In your user profile the department number is stored as a 'term' using a managed metadata field.
It's important to know that a 'term' can be translated or you can even define synonyms.
When using managed metadata in search, search will use the id (=a guid) of the term instead of the actual text ('613').
Since it ignores the text (and uses the id of the term), this makes it possible for search to find your term in any language or synonyms.
In your case translation of '613' is not really applicable but imagine that your department was a text instead of a number.
When searching on the term 'HR', search could return all the items with 'HR' but also the ones with 'personeelsdienst' (HR in Dutch).

CAML Query with Contains and Or Clause Issue

What I want to achieve : Take a keyword array as input and query Sharepoint List to return all rows which contain the keywords in the list.
I have built a simple CAML query to query my list with one keyword (pdf) .
<Query><Where><Contains><FieldRef Name='Keyword'/><Value Type='Text'>pdf</Value></Contains></Where></Query>
This works fine.
But, when I try to use Or clause in the CAML query(see below), I get the following error
"One or more field types are not installed properly. Go to the list settings page to delete these fields."
<Query><Where><Or><Contains><FieldRef Name='Keyword'/><Value Type='Text'>pdf</Value></Contains></Or></Where></Query>
I googled for the syntax and everything looks good. Please let me know what is missing.
Thanks in advance.
In CAML Query if you want to use OR you must and should have 2 conditions.
The field reference name must be the internal name. You can find this by going to the colmn page in list/library settings and the name is the end of the URL. Spaces and underscores in the name must be handled differently.

How to create a lookup column that targets a Doc Lib and uses the 'Name' of the document?

How do you create a lookup column to a Document Library that uses the 'Name' of the document as the lookup value?
I found a blog post that recommends adding another custom field like "FileName" and then using a item reciever to populate the custom field with the value from the Name field but that seems cheesy.
Link to the blog in case people are interested:
http://blogs.msdn.com/pranab/archive/2008/01/08/sharepoint-2007-moss-wss-issue-with-lookup-column-to-doc-lib-name-field.aspx
I've got a bunch of custom document content types that I dont want to clutter with a work around that should really work anyway.
I created a one step workflow to set the title from the name, fired on modify and created. Seems to work and took seconds to create.
One way you can do this (although not the easiest way) is by creating a custom field type that extends the SPFieldLookup class. SharePoint's field editor for Lookup fields purposefully hides any columns types that aren't supported by Lookup fields, but you can create a field editor for your custom field type that shows them.
However, I have created a Lookup column that points to a Name column in a Document Library before, and it probably doesn't work like you'd expect. While the value stored in the lookup column is valid, it doesn't show up right in List view or on the View Properties form.
The solution you posted may actually be the best way to handle this. Lookup fields require some kludges if you want to handle more complex scenarios, but that's because they're not meant to provide the same functionality as a foreign key relationship in a database.
Coding in any form always scares me. So Here's what I did: I simply renamed the Stupid "Title" Field to something else, say "Keywords", since you cant do anything with that field: cant even make it mandatory.
Then I created another Single line field called "Title" and used this field for the Lookups
Well there is a simple solution to that and in might work in some case.
In the nutshell if you make the Title field Mandatory, this will force the user to enter a title. In that manner we can use title field as a lookup field.
Now How to do that?
One you are done create a document library go to the library setting. Select Advance Setting and Select Yes for the option "Allow management of content types?".
Then go back to the Library setting and Under content types select the "Document" Content type. THen Select Title Column and then Select "Required (Must contain information)" and say OK.
Now try uploading a document to this document library. You will see Title field in the form.
Hope this helps
Cheers
Vaqar
You have to add the field as XML with the ShowField as 'FileLeafRef'
var XmlFieldDefinition = "<Field DisplayName='myLookupColumn' Type='LookupMulti' StaticName='myLookupColumn' Name='myLookupColumn' Required='FALSE' List='THE LOOKUP ID HERE' WebId='THE WEB ID HERE' UnlimitedLengthInDocumentLibrary='TRUE' Mult='TRUE' Sortable='FALSE' ShowField='FileLeafRef' />"
Field fld = fieldCollection.AddFieldAsXml(XmlFieldDefinition, true, AddFieldOptions.DefaultValue);
ClientContext.Load(fld);
ClientContext.ExecuteQuery();

Resources