SharePoint Dragons

Nikander & Margriet on SharePoint

Monthly Archives: June 2012

SharePoint Max Dragon – checks for capacity planning limits

We decided to rename the Maxer tool ( https://sharepointdragons.com/2012/05/25/maxer-and-beads/ ) to the SharePoint Max Dragon, for the reasons discussed at http://blogs.technet.com/b/wikininjas/archive/2012/06/04/interview-with-margriet-bruggeman-sharepoint-author-sharepoint-technet-forum-admin-former-sharepoint-mvp-maxer-creator-and-sharepoint-2012-guru.aspx?CommentPosted=true#commentmessage You can get it here: http://gallery.technet.microsoft.com/Maxer-for-SharePoint-2010-8cd0f26f

The TechNet Wiki interview with Margriet

Read the Monday interview with Wiki Ninjette Margriet at http://blogs.technet.com/b/wikininjas/archive/2012/06/04/interview-with-margriet-bruggeman-sharepoint-author-sharepoint-technet-forum-admin-former-sharepoint-mvp-maxer-creator-and-sharepoint-2012-guru.aspx Check out the “Iris and the Little Moon Bear” drawing!

How about Documents and Metadata using SharePoint 2010?

What do I do with Metadata and Documents? Is it possible to inherit Metadata?  Do I use Folders or Document Sets? This blog post provides the answers to these questions.

Folders & Metadata

It is possible to set default Metadata for every folder in your Document Library. You can set defaults on all of the subfolders from the root, by default this will be inherited.

Follow the next steps to do this:

  1. First you have to create the folders  and columns you want.
  2. Go to the Document Library
  3. Go to Library Settings
  4. Click Column default value settings (General settings)
  5. Select the folder (left) where you want to set a default
  6. Select the column that you want to use
  7. Set the default value for the column > click OK

image

That’s all! If you upload a document in the folder where you have set a default Metadata value, this value will be automatically filled.

Note: More information about SharePoint 2010 Best Practices Folders can be found at  https://sharepointdragons.com/2012/03/27/sharepoint-2010-best-practices-folders-not-necessarily-considered-evil/

Document Sets & Metadata

If you have multiple documents that are part of a single project or tasks you can use a Document Set. With Document Sets you can group ,multiple documents and share the Metadata en versioning. In a Document Set you can pass Metadata from the Document Set to the documents in the Document Set.

Follow the next steps if you want to use Document Sets. First you have to enable Documents Sets in the site collection:

  1. Go to Site Actions
  2. Go to Site Settings
  3. Go to Site Collection Features
  4. Click Document Sets

Note: Take a look at the following page if you want more information about which feature you need to activate: https://sharepointdragons.com/tag/features/

After activating the Documents Sets site collection feature you can use Documents Sets in your Document Libraries

  1. Create a Document Library
  2. Go to Library Settings
  3. Go to Advanced Settings
  4. Allow management of content types > click OK
  5. Go to Add from existing site content types
  6. Add Document Set > click OK
  7. Go the the Document Library
  8. Click Documents
  9. Click New Document Set

image

Via the Document Set Settings page you can select which column values from the Document Set  should be automatically synchronized to all documents in the Document Set.

  1. Go to the Document Library
  2. Go to Library Settings
  3. Click Document Set (Content Types)
  4. Click Document Set settings

image

If you upload a document (or multiple) into the Document Set you will notice that the column values are synchronized.

Why is SPListItemCollection.Count so slow?

There are situations where people experience disastrous response times when trying to count the number of items in a collection or folder. Why does this happen? A long time ago, we wrote about this at http://www.loisandclark.eu/Pages/Velocity.aspx . Basically, looping thru a collection and calling the Count property leads to a huge amount of SQL queries that are fired, resulting in a disappointing performance.

The best thing you can do in such a situation is establish what happens under the covers, and take actions accordingly. Usually, people advise to do this using SQL Server Profiler, which works fine for dev scenarios, but isn’t recommendable (because of performance reasons) in a production environment. Instead, you’d be better of executing a SQL DMV query that identifies the currently running SQL queries. Such as this one:

SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

SELECT er.session_Id AS [Spid] , sp.ecid , DB_NAME(sp.dbid) AS [Database] , sp.nt_username , er.status , er.wait_type , SUBSTRING (qt.text, (er.statement_start_offset/2) + 1, ((CASE WHEN er.statement_end_offset = -1 THEN LEN(CONVERT(NVARCHAR(MAX), qt.text)) * 2 ELSE er.statement_end_offset END – er.statement_start_offset)/2) + 1) AS [Individual Query] , qt.text AS [Parent Query] , sp.program_name , sp.Hostname , sp.nt_domain , er.start_time

FROM sys.dm_exec_requests er

INNER JOIN sys.sysprocesses sp ON er.session_id = sp.spid

CROSS APPLY sys.dm_exec_sql_text(er.sql_handle)as qt

WHERE session_Id > 50

AND session_Id NOT IN (@@SPID)

ORDER BY session_Id, ecid

SQL DMV query techniques are discussed in the excellent book http://www.amazon.com/SQL-Server-DMVs-Action-Management/dp/1935182730/ref=sr_1_1?ie=UTF8&qid=1338967190&sr=8-1 . We were technical reviewers for this book, and will devote a separate blog post to this book, but if you’re interested, check it out.

The Wiki Ninjette

The Top 10 TN Wiki ninja’s page is always great fun: http://blogs.technet.com/b/wikininjas/archive/2012/06/03/top-10-wiki-ninjas-margriet-bruggeman-s-sharepoint-2012-best-practices.aspx. Margriet’s activities of last week led to the one and only TN Wiki Ninja stick figure:

SQL Server MVP Deep Dives

Frequently, we act as technical reviewers for IT books. Now and then we devote a blog post to discuss one of these books. Today, we’re discussing SQL Server MVP Deep Dives Volume 2: http://www.amazon.com/SQL-Server-Deep-Dives-Volume/dp/1617290475/ref=sr_1_2?ie=UTF8&qid=1338292364&sr=8-2 It’s the most congenial IT book we ever saw, since the authors donate their proceeds to http://www.operationsmile.org/. The book is written by an impressive number of SQL Server MVPs (we believe approx. 60 of them) and each one donates a chapter of around 10 pages long. Therefore, it reads more like a bundled collection of blog posts than a book, but you’re bound to learn something from it. One comment we’ve heard quite often that it is a very good read while travelling (a result of the diverse and short chapters).

Enabling the workflow DSL for a custom acitivity

Here’s a small trick for enabling the workflow DSL for a custom activity:

  1. First, create a new empty SharePoint project.
  2. Add a  reference to the System.Workflow.Activities assembly. It’s located in the GAC, and therefore it may be a bit of a hassle to reference it. For cases like these, we like to use Muse.VSExtensions ( http://visualstudiogallery.msdn.microsoft.com/36a6eb45-a7b1-47c3-9e85-09f0aef6e879 ) from the Visual Studio gallery. It adds a new menu option called Add GAC Reference that allows you to search for and reference assemblies in the GAC directly. If that’s not enough, it also adds a menu option that removes unused references. It’s a great tool, that works like a charm.
  3. Also add a reference to System.Workflow.ComponentModel.dll, also located in the GAC.
  4. Add a new class: 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Workflow.Activities;

namespace SharePointProject1
{
    public partial class Class1 : SequenceActivity
    {
        public Class1()
        {
            InitializeComponent();
        }
    }
}

Finally, add another class called class1.designer.cs:
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SharePointProject1
{
    public partial class Class1
    {
        private void InitializeComponent()
        { }
    }
}

Now, when you click class1, you’ll find that now you can drag n drop activities. See http://social.technet.microsoft.com/Forums/en-US/sharepoint2010programming/thread/23f11f0f-d50d-4f99-a409-90f582b19442 for more info.