Jan 31, 2009

SPTip : Show Custom Locations in Office File Dialogs

By this time many companies use SharePoint as their central document repository. To simplify and accelerate the access, it would be comfortable to add a link to the Office “My Places” bar. The My Places bar appears in the left pane of both the Open and the Save As dialog boxes in Microsoft Office programs.

image

To add an item create the following registry key:

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\Open Find\Places\UserDefinedPlaces\Place0]
"Name"="Document Center"
"Path"=http://mysharepoint/Docs/

image

You can also hide items you don’t need. Read more on the MS Knowledgebase: How to customize the My Places bar in both the Open and the Save As dialog boxes in Office

To deploy the key to all clients in the domain you can use group policies.

Jan 25, 2009

Self-Awareness With Twitter

Have you ever take a look at your Twitter cloud?

My Twitter cloud:

image

taken from http://twitter.grader.com/cglessner

What does this tell about me?

The largest cloud is “my” followed by “SharePoint” and “PowerShell”:

I’m a selfish SharePoint-PowerShell geek!

Psychoanalyzing with Twitter – just great!

Or maybe this is market niche for fortune-tellers. Tarot cards and crystal balls are snows of yesteryear. Read the future in the clouds…

What does the clouds tell about you?

Jan 24, 2009

Publish Major Versions & Declarative SharePoint Workflows

In general there are four start options for SharePoint workflows:

  • Start manual
  • Start when an item changed
  • Start when a new item is created
  • Start workflow to approve publishing a major version of an item

When you use Visual Studio workflows or the built-in MOSS Approval Workflow you have all options. But with declarative workflows like SharePoint Designer and Nintex Workflows you have only the first three options.

  • Start workflow to approve publishing a major version of an item

You can’t use declarative workflows to approve publishing a major version of an item. Lose that option can really hurts!

image

Take a look at the SharePoint object model

In the object model the DefaultContentApprovalWorkflowId property of the SPList contains the the id of the workflow association which should be started to publish a major version.

So we only need to find the association id of our declarative workflow and set the DefaultContentApprovalWorkflowId property – maybe with PowerShell?

Yes and No! This works until the association id will change. And it will change every time the workflow changes! Manual set the DefaultContentApprovalWorkflowId every time the workflow changes? Cumbersome!

The solution

Declarative workflows (xoml files) will be stores in a hidden document library. You can see the library in SharePoint Designer:

image 

Just let an event receiver do the work! Every time the workflow file changes get the new association id and set the DefaultContentApprovalWorkflowId of the target list.

PowerShell Implementation

Exemplarily I will show an implementation with PowerShell and PowerEventReceiver.

#workflow must be associated with the target list $workflowFileName = "Nintex Test.xoml"
$targetListTitle = "TestLib"

function ItemUpdated()
{

if($item.DisplayName -eq "$($workflowFileName).wfconfig")
{

$binFile = $item.File.OpenBinary() $wfConfig = [xml][System.Text.Encoding]::UTF8.GetString($binFile)

$baseId
= [Guid]$wfConfig.WorkflowConfig.Template.BaseID

$lib = $web.Lists[$targetListTitle]

$assoc = $lib.WorkflowAssociations.GetAssociationByBaseId($baseId)

$lib.DefaultApprovalWorkflowId = $assoc.Id $lib.Update()
}
}

image

  • Change $workflowFileName and $targetListTitle appropriately. The workflow should already be deployed on the target list. Manual start option must be activated for the workflow. You can find the file name of the workflow with help of SharePoint Designer or PowerShell.
  • Save the script and resave/republish the SPD/Nintex workflow.
  • Publish a major version of a document:

image

  • After entering a comment you’ll see the initiation form of your content approval workflow. In my case a beautiful Nintex Workflow, in other cases an ugly SharePoint Designer Workflow ;-)

image

  • Start

image

Now you can change the workflow without lose the content approval workflow.

Jan 20, 2009

Software, Open Source And The Theory Of Evolution

Have you ever thought about software, open source and Darwin’s theory of evolution? No?

What is evolution?

In biology, evolution is change in the inherited traits of a population of organisms from one generation to the next. These changes are caused by a combination of three main processes (Wikipedia):

  • reproduction
  • variation
  • selection

How does this works?

An evolving entity must be able to reproduce (reproduction). These copies can slightly vary from the source (variation). Some of this variations will survive and reproduce better than others (selection). The copies surviving better will become more common in population (the fittest will survive). This process will run from generation to generation from the beginning. Is this a powerful mechanism? Take a look in the mirror!

What to hell has this to do with Software and Open Source?!

Source code, the building block of software, is simple to reproduce – copy & paste (reproduction). If you share the source code on a blog, on a open source platform like CodePlex or on a script repository like http://poshcode.org, others will copy and slightly modify the original code (variations). Slightly, because the chosen code must fit some to the problem domain. Some of these variations will be better than the original source. If the variations will be republished, better code variations will be used and reproduced more often, consequently become more common in the internet (selection). This process will run from code generation to code generation from the beginning.

What’s about compiled code? Compiled code is also simple to copy, but copying doesn’t produce variations. Consequently compiled code can’t evolve!

Open source is the booster for the evolution of software!

In fact many processes out there are related to the theory of evolution. A gen is a blueprint for the production of a protein. What’s a business process? Maybe a blueprint for producing a car. Can we reproduce processes? Can processes vary? Can we select processes? What is benchmarking? There are many questions left to ask….

Jan 19, 2009

iLSP - SharePoint Designer “Execute SQL” Action

With the “Execute SQL” action you can execute SQL statements from within SharePoint Designer workflows.

The action is included in my SharePoint Designer Actions 1.0 release on CodePlex. Source code is available.

Documentation

Configuration in SharePoint Designer

image

  • Provider: The .NET ADO Provider. Default is MS SQL Server (System.Data.SqlClient). You can use other providers like ODBC, Oracle…
  • Connection: The connection string e.g. “Data Source=localhost\SQLExpress;Initial Catalog=test;Integrated Security=SSPI”
  • SQL: The SQL statement you want to execute. You can use Lookups to parameterize the statement. You can also use stored procedures e.g. “EXEC [test_Proc] @var1=N’test’ ”

image 

  • Result: The variable where you want to store the first column of the first row of the result from the SQL statement. Actual the result variable is mandatory. If you don’t need it you have to use dummy variable.

NOTE: The action runs under the user account of the application pool

iLSP - SharePoint Designer “Create Site” Action

With the “Create a site” action you can create SharePoint sites from within SharePoint Designer workflows.

The action is included in my SharePoint Designer Actions 1.0 release on CodePlex. Source code is available.

Short Documentation

Configuration in SharePoint Designerimage

Note: The activity creates the site while execution. From a WF design point of view, it would be preferable to do heavy work in a Work Batch.  Maybe I show this in another post…

My Sessions on BASTA! Spring 2009

On the SharePoint Days (Germany) at 25th February 2009 I’ll have two sessions:

Mega Merger (SharePoint & PowerShell)

Nintex Workflow 2007

Would be glad to see you…

Jan 18, 2009

iLSP - SharePoint Designer “Get Parent Folder” Action

This action can be used to get the list item id of the parent folder of an item. After you got the id of the folder you can use it with any other SPD action.

The action is included in my SharePoint Designer Actions 1.0 release on CodePlex. Source code is available.

Example scenario: Approver Folder Inheritance

You need a document based SharePoint Designer approval workflow with different approvers and permissions depending on the department of the document. But you don’t want to assign the approvers and permissions for each document individually! To inherit the permissions you would create for each department a folder and assign the permissions to it. Also you want to assign the approvers to the folder, because all documents within have the same approvers. But how you can get the approvers from the folder in the workflow? This is where the “Get Parent Folder” action comes in.

Step by Step

  • Create a site column named “Approvers” type of “Person or Group”, allow multiple selection.

image

  • Create a site content type named “Approval Folder”, as parent content type choose “Folder”

image 

  • Add the previous created site column to the just created content type

image

  • Create a Document Library named “Approval Documents” and allow content types (Advanced Settings)

image 

  • Add the previous created site column to the just created content type

image

  • Create a Document Library named “Approval Documents”

image

  • In the “Advanced Settings”  allow content types

image

  • Add our “Approval Folder” content type to the document library

image

  • Create a new “Approval Folder” named “Development” and assign the approvers (in this example myself and the administrator)

image

At this point we could start with the SharePoint Designer Workflow. To simplify the scenario I don’t set the approval status and simply create a to do item for the approvers.

  • Create a new Workflow named “Approver Folder Inheritance”
  • Add the “Get parent folder” action from the category “iLove SharePoint”

image

  • For “this list” choose current item

image

  • To store the “Result” create a new workflow variable type of “List Item ID”

image

  • Now we have the list item id of the folder. To get approvers add a “Build Dynamic String” action.
    • Click on “dynamic string” choose “Lookup Value” in the editor. In the lookup details choose as source “Approval Documents” and for field “Approvers”. To select the folder item choose ID as field. To choose the value click on “fx”, select “Workflow Data” and “folderId” as variable.

image

    • Store the dynamic string in a new Workflow Variable named “approvers” and type of “Text”
    • Next, add an “Assign a To-Do Item” action. Name the to-do item task “Approval Task”. In the people picker double click on “Workflow-Lookup”, choose “Workflow Data” and the “approvers” variable.

image

  • Now we can save and test the workflow. Upload any document into the “Development” folder and start the workflow. The workflow creates tasks for the approvers we have assigned to the Development folder.

image

  • That’s it.

By the way: I don’t like SharePoint Designer Workflows , I prefer Nintex Workflow!

Jan 13, 2009

Just Born: Lilly May Glessner

After a long and drawn out wait, Jenny and I are proud to announce the birth of our wonderful daughter! Lilly May was born at 6th of January 2009, at 21:52pm weighing in at 3,040kg and 52cm in length.

lilly-may