Saturday, May 5, 2012

List Settings Error 0x80070024

Recently we faced a problem accessing "List Settings". The error said "The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator. 0x80070024." The List Settings page was working fine in the other site collections.

We created one custom list with one item. The list has the same issue even though it has single item.

We found an entry in ULS Logs saying "big list, slow query operation" The log has mentioned the List GUID which is being queried. I wrote a Powershell to find the list. The list is hidden "Workflows" document library. I tried the document library URL in browser, it returned me "404 Not found". One of my colleague used the list guid with _layouts/listedit.aspx(application page List Settings refer) and it did show us the Library settings. We verified the library settings but it did not helped.

I wrote a PowerShell to find the number of items in the list and it returned 0. So there are no items but still it is causing the issue. We were clueless about the behavior. I wrote the below PowerShell script, executed it, and there were no errors on hitting the "List Settings".

$web=Get-SPWeb [webUrl]  #remove the square bracckets here
$list=$web.Lists["Workflows"]  #Keep the square brackets in this line.
$list.EnableThrottling=$false
$list.Update()

For the time being, we used this solution. I am investigating the cause for the issue. The "Workflows" document library is used to store the site level workflows. The library is created by SharePoint Designer (SPD) on first ever SPD workflow creation in the site.

Visit again, for the updates!
[Update 05/08/2012: I found that the "Workflows" library reports -1 in ItemCount. As such, no list or library should report ItemCount as a negative number. As mentioned in this post, Microsoft has accepted that MOSS 2007 has the issue of negative ItemCount. The site, we are referring to, is a migrated site. So the library was reporting negative ItemCount. Negative item count is a cause for failure of indexing operation. If indexing fails, queries perform slow. It was causing the throttle issue even though the "Workflows" library is empty.

Resolution: If the "Workflows" library is empty, delete it. SharePoint Designer will recreate the library on SPD workflow creation. If the library is not empty, then there will be no issue as ItemCount will always report positive number.

The issue may occur only in migrated sites hoping that Microsoft has taken care of the issue in SharePoint 2010.]

Sunday, April 29, 2012

Missing "Manage Permissions" in Document Library

While working on a site, I encountered a document library where it was showing fewer menus in Edit Control Block (EBC) (also referred as List Item Menu). I noticed there is absence of "Manage Permissions" menu. It was a clear indication that document library has been broken. I tried to figure it out looking at the list schema, field schemas, views etc. but of no use.

"Manage Permissions" is the essential menu item to manage the item level permissions. Client was also interested in it.

The document library was the only one which was misbehaving in the site.

After looking at various options, I realized that we can provide "Manage Permissions" link using Custom Action.

SharePoint Designer 2010 has made it very easy to create Custom Action. Custom Actions can be created to display the new/edit or display form, to initiate a workflow or to navigate to a url. Custom Actions also support URL tokens such as {ListId}. I just observed the "Manage Permissions" link in other document libraries and analyzed the URL with query string parameters.

"Manage Permissions" navigate to : _layouts/user.aspx (application page)
Query string comprises of obj (it has list id/GUID, item id and entity category), and list (it has list GUID).

URL looks like as below:
http://server/<weburl>/_layouts/user.aspx?obj=<list Id>,<item id>, LISTITEM&List=<list id>

Custom Actions support various URL tokens. I referred the below URL tokens.
  1. {ListId} --List Guid
  2. {ItemId} -- Item Guid
My URL for custom action :

http://server/<weburl>/_layouts/user.aspx?obj={ListId},{ItemId},LISTITEM&List={ListId}

That's it! I named my custom action as "Manage Permissions". This is just a workaround. We will investiagate the reason behind misbehave and update the post.

Thursday, April 26, 2012

Filterable Multi-valued PeopelPicker Column using PowerShell

Recently I came across an error while filtering the multi-valued PeoplePicker column. The error reads "Cannot show the value of filter. The field may not be filterable, or the number of items returned exceeds the list view threshold enforced by the administrator." There are only four values in the column, surely it has no rleation to the list view threshold value.

Internally, SharePoint server uses "_layouts/filter.aspx" application page for filter values which are presented in an iFrame. I checked the ULS logs and copied the Request URL with filter.aspx. I pasted it in browser and hit "Enter". It returned no result.

What is multi-valued field?
The field which allows more than one values or which allows multiple selections. The multi-valued fileds are non-sortable, non-filterable. Multi-valued fields cannot be indexed.

Fix:
This behavior can be overridden. Every field has an associated schema. Multi-valued fields are marked as "Sortable =false" in the schema for performance reasons. Note: Apply the workaround wherever it is unavoidable.

If we mark the multi-valued PeoplePicker as "Sortable=true", the column turns filterable/ sortable. This can be achieved using SharePoint Server Object Model or using Windows PowerShell (I love it).

PowerShell Script to mark the column as Sortable:

$web=Get-SPWeb <weburl>
$list=$web.Lists[<list title>]
$field=$list.Fields[<field title>]
$strSchema=$field.SchemaXml
$str=Schema$strSchema.Replace("Sortable=`"FALSE`"","Sortable=`"true`"")
$field.SchemaXml = $strSchema
[Update: I noticed that multi-valued "person or group" coulmn in other web application was showing filter choices even though "Sortable=false". Googling did not help. I checked at various levels and found that "Online Presence" setting causes this error. If Online presence setting is turned OFF, SP 2010 starts showing this error for multi-valued columns when tried to filter. So turn it ON, and...no error, filter choices are shown back. The Online Presence setting is available in Web applications's General Settings.]

Sunday, April 8, 2012

Powershell to find site collections with specific feature activated

This is a one liner Powershell to find site collections which have the specific feature activated. See the below example, it display URLs of site collections where "SharePoint Publishing Infrastructure" feature is activated. The "PublishingSite" is the name of publishing infrastructure feature.

Get-SPSite -Limit All| Where-Object {(Get-SPFeature "PublishingSite" -ErrorAction SilentlyContinue -Site $_.Url) -ne $null } | Select Url

So the format is

Get-SPSite -Limit All | Where-Object { (Get-SPFeature <Feature Name> -ErrorAction SilentlyContinue -Site $_.Url) -ne $null } | Select Url

Note that it will only check for site collection scoped features. The above Powershell can be modified for web scoped features as below.

Get-SPSite -Limit All| Get-SPWeb -Limit All | Where-Object { (Get-SPFeature <Feature Name> -ErrorAction SilentlyContinue -Web $_.Url) -ne $null } | Select Url

e.g. To check Publishing feature activation status at web scope, it will look like as below. "PublishingWeb" is a web scoped feature.

Get-SPSite -Limit All| Get-SPWeb -Limit All | Where-Object { (Get-SPFeature "PublishingWeb" -ErrorAction SilentlyContinue -Web $_.Url) -ne $null } | Select Url

This powershell block can be extended for web application/Farm scoped features also.

Friday, December 2, 2011

Information Architecture and Faceted Navigation in SharePoint 2010

SharePoint 2010 has new features included (such as Taxonomy, Document Sets) and search improvements (such as Refiners). This has brought in a whole lot of changes to the thought process related to information architecture.

In MOSS 2007, we dealt with a linear guided navigation. SPS2010 improvements and new features introduced faceted navigation. It is also referred as faceted search or (free form) guided navigation. The faceted search presents users with a list of relevant suggestions for refining the search results by document type, site, author, modified date, tags etc.

Information architecture is the key in designing the content management systems, knowledge management portals, e-Commerce sites and so on. Consider below points while deciding on Information architecture.

• Content Roll up: Using Content Query web part, relevant and related content can be made available on content pages, document set welcome pages etc. Content Query web part has few improvements related to managed metadata (taxonomy) columns. Read here what’s new in content query web part.
• Refiners: This is a key to faceted search. The refinement web part can be used to narrow the search results.
• Extensibility of Search Web part: SPS 2010 has search web parts which can be extended. In MOSS 2007, these web parts are sealed. Scenario based search functionality can be extended and used on various pages, document set pages.

I have listed here few of the points. There are many features in SPS 2010 which we can exploit for the better information architecture and good navigation providing better user experience.
Few links about faceted search and information architecture.
Building Information Architecture in SPS 2010
Faceted Navigation
How Microsoft is leveraging the features in Infopedia and Microsoft Academy Mobile
Case Study: Microsoft Infopedia

Tuesday, August 2, 2011

SharePoint: Site Columns and Content Types

There are various posts on the internet describing the site columns and content types. In this post I am co-relating these with concepts of objects and classes. This will help the developer visualize these concepts differently.

Content and Object

Object has data. Class provides the set of attributes to detail the object instances.

Content is data. Content has two categories: Structured and Unstructured.

Content comprises of documents and list items. Content does not include list or library itself. List or library helps user to organize the content.

Structured content is the one which separates its storage from its display. e.g. List Items can be sorted/filtered and viewed in List web part or data row in a SQL data table.

Unstructured content is the one which cannot be viewed separately the format in which they are stored. e.g. Word document cannot be viewed without the MS Office Word.

Content type provides the set of attributes to define the metadata about content. The attributes are provided in the form of columns/fields in the list or at the site level.

Site Column

When the column is defined at site level, it is a site column. The site column is reusable across all lists and libraries in the site.

This is very similar to have property declared in an interface and will be available across all objects implementing the interface.

Content Type

Content type is a set of site columns. The site column helps in describing the content. The content type can be used across the lists and libraries in the site.

This is just like a complex data type. The data types/ classes has properties to describe the object.

Wednesday, April 13, 2011

Document Library Creation with Specific Document Template Using Server Object Model

Introduction: There is no way in SharePoint UI to create a document library with blank Excel/PowerPoint document template. But it is possible to create a document library with such document templates programmatically.

Technicalities:
I will first take you through the classes involved in development.


  • SPListCollection

  • SPListTemplateType

  • SPListTemplate

  • SPDocTemplate


SPListCollection has Add method with 7 overloads. Look for the method signatures here.



We will concentrate on the following signature:



public virtual Guid Add(
string title, //Title for the library
string description,//Description about the library
SPListTemplate template,//The list template. We are interested in Document Library.
SPDocTemplate documentTemplate //The document template for library.e.g. Excel, Word or Powerpoint etc.
)

SPListTemplateType is a enumeration. The enumeration has underlying integer values which match the Type attribute of ListTemplate element. Please visit here for details.


SPListTemplate represents the list definition or list template for the list. The list definition/template has the views and fields defined. SPWeb.ListTemplates returns the list definitions for the web site. SPSite.GetCustomListTemplates method returns the list template collection for the site collection. More details.



SPDocTemplate represents the document template. Whenever we create a document library, it is created by using blank Word Document template. There are many document templates available in SharePoint 2010 OOB. The document templates have IDs. The ID is used to filter the document template collection presented by SPWeb.DocTemplates property. Document Template IDs list follows:












Document Template IDDescription
101A blank Microsoft Word 97-2003 document.
103A blank Microsoft Excel 97-2003 document.
104A blank Microsoft PowerPoint 97-2003 document.
105A blank Microsoft basic page ASPX document.
106A blank Microsoft Web Part Page ASPX document.
111A basic Microsoft OneNote 2010 Notebook.
121A blank Microsoft Word document.
122A blank Microsoft Excel document.
123A blank Microsoft PowerPoint document.


Code:

using (SPSite site = new SPSite(serverUrl)) {
using (SPWeb web = site.OpenWeb()) {
SPListTemplate lstTemplate = web.ListTemplates["Document Library"];
SPDocTemplate docTemplate =(from SPDocTemplate dt in web.DocTemplates
where dt.Type == 122
select dt).FirstOrDefault();
Guid newLibID =
web.Lists.Add("Expense Claims", "Excel Expenses", lstTemplate, docTemplate);
SPDocumentLibrary newLib = web.Lists[newLibID] as SPDocumentLibrary;
newLib.OnQuickLaunch = true;
newLib.Update();
}
}



The code is for console application.(I know you are aware, just for clarity).