Wednesday, June 19, 2013

SharePoint 2013 Book is ready to purchase

If you are looking for a sharepoint 2013 end-user specific book, look no further

Monday, May 20, 2013

Activating the Document ID feature by code causes document sets welcome pages to show each web part twice

This is a weird one - I have a feature, that when activated loops over a list of other features and activates them - using "Force" :

site.Features.Add(currentFeatureID, true);


This works fine on most sites, but in Document Center sites, where the document ID feature is already activated document sets in the site suddenly show the web parts on the welcome page twice. I debugged it, and it turns out that this happens when the document ID feature is the culprit. However, this doesn't happen if I activate the ID feature using powershell.


My only solution at the moment is to check if the feature is already activated before activating it. This stopped the problem, but doesn't explain it.

Sunday, May 19, 2013

Finding if a site column exists in a site, by ID

Scenario - you have an ID of a site column (SPField belonging to SPWeb)and you want to find out if there is a field by that ID in the collection.


Problem: if you try something like:


web.Fields[fieldID] == null




The result is an exception if the field doesnt exist. What a shame.

The solution is to use the Contains method of the Fields collection:


web.Fields.Contains(fieldID)


*Thanks Ofer Gal for pointing this out.

Thursday, February 21, 2013

Fields not sortable or filterable

A client alarmed me today, showing me that in one document library a field I created didn't allow users to filter or sort on it. I couldn't find why in that library it did that, while the same site column in all other libraries allowed filtering and sorting. Checking in sharepoint manager showed no difference between the field in the different libraries - so I was stuck on that one as well.

After a while it dawned on me - the difference between the libraries was that in the one that was misbehaving the column was specified as a key filter - to help users filter and sort on it from the metadata navigation panel. This disabled the sort and filter in the list view.

Learn something new everyday = high blood pressure for the rest of your life.

Sunday, January 13, 2013

Folder sorting in views

A client has alerted me to an unexpected behavior of list views where folders are involved.
The client wanted to make sure the folders are always on the top of the view, regardless of sort order, and, looking at the settings of the view it should have happened. However, seemingly at random some document libraries stopped doing that, while other libraries were fine.
After digging into it a bit, I realised what the issue is: enabling and disabling folders.

You see, the client had custom folder content types added to some of the document libraries, and in those libraries the client wanted to make sure the users don't create folders of the built-in content type using the "New Folder" button in the ribbon. To achieve this, they changed the setting in document library advanced settings to not "Make "New Folder" command available?".
Turns out that when this setting is set to "no", there are other ramifications than just not showing the new folder command. It also tells views to behave as it there are no folders - and treat all folders items. Result - in those libraries folders were sorted with items, and were not at the top of the views. Makes sense if you consider that that setting is mapped to the SPList.
EnableFolderCreation
in code - meaning it tells the list that folders are not available - even though you can still create folder using the "new" button and choose a content type that inherits from folder.
To resolve this, we made sure the "Make "New Folder" command available?" option is always set to "yes", but we activated a feature that disabled the new folder button itself - not touching the document library setting.

Sunday, January 06, 2013

SharePoint error 0x81020030 Invalid file name

If you try to upload a file to a sharepoint document library, and get an error about invalid file name or url, it could be that your problem has nothing to do with the file name - it could be a problem with a corrupt column that has been added to the document library.

In my case, I had to remove column by column until I found that the issue goes away if I remove a calculated column that I created using a feature (using CAML), and the XML definition of the column was missing a critical attribute - the ResultType attribue. Adding that attribute to my XML solved the problem.