How to create a search column for Doc Lib and use the "Name" of the document?

How to create a search column in a document library that uses the "Name" of a document as a search value?

I found a blog post recommending adding another custom field of type FileName and then using the receiver element to populate the custom field with the value from the Name field, but it seems crappy. 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 have a bunch of non-standard types of document content that I don't want to clutter up with work that should work anyway.

+3
source share
5 answers

One way to do this (though not the easiest way) is to create a custom field type that extends the SPFieldLookup class. The SharePoint field editor for Lookup fields purposefully hides column types that are not supported by Lookup fields, but you can create a field editor for your custom field type that displays them.

However, I created the Lookup column, which used to point to the Name column in the document library, and it probably doesn't work as you expected. Although the value stored in the search column is valid, it does not display correctly in the List view or in the View Properties form.

, , . kludges, , , , .

+2

, , . , , .

+4

. , : "" , " ", : , . ""

+1

, , . , "" , . , .

? , . " " "" " ?". , " " " ". THEN " ( )" "".

. Title .

, Vaqar

0

XML ShowField '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();
Hide result
0

Source: https://habr.com/ru/post/1702446/


All Articles