Tam Tam
 

Document ID Provider, the last one?

21

Jun

For a client of ours we wanted to create a Custom SP2010 Document ID Provider. For this provider I wanted to be able to adjust and configure it so I can use it for other customers also.
First I needed to know how to create a Document ID Provider and found that: Tobias Zimmergren had an excelent article on creating you own SP2010 Document ID Provider.

Next in order to create a unique sequenced number I immediatly thought of SQL Server. And found that Ton Stegeman had an equally usefull post on how to create your own SPDatabase object in a SharePoint Farm.

Now I was set to create "the last Document ID Provider" for SP2010 I was ever going to write. Perhaps not but still, it should suffice for a LOT of clients of us!

I wanted to end up with an admin page like this:

This should then result in this document id:



So how to do this?
Step 1
Create a Database with a Table where I can store my generated document id's

CREATE TABLE [dbo].[scoped_docid](
	[id] [bigint] IDENTITY(1,1) NOT NULL,
	[scopeid] [uniqueidentifier] NOT NULL,
	[objectid] [uniqueidentifier] NOT NULL,
	[scopedocid] [bigint] NULL,
	[scope] [varchar](100) NULL,
	[generateddocid] [varchar](150) NULL,
	[listid] [uniqueidentifier] NULL,
	[webid] [uniqueidentifier] NULL,
	[siteid] [uniqueidentifier] NULL,
	[webapplicationid] [uniqueidentifier] NULL,
	[farmid] [uniqueidentifier] NULL,	
	[created] [datetime] NULL,
	CONSTRAINT [PK_scoped_docid] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

And a stored procedure to Get/Insert ID's:

-- =============================================
-- Author:		Stef van Hooijdonk
-- Create date: juni 2010
-- Description:	
-- =============================================
CREATE PROCEDURE GetNextScopedDocID 
	-- Add the parameters for the stored procedure here
	
	@scopeid uniqueidentifier  ,
	@scope varchar(100), 
	@itemid uniqueidentifier  
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;
	SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

	BEGIN TRANSACTION

	declare @result bigint
	declare @scopedindex bigint

	select @scopedindex=COALESCE([scopedocid],-1),@result=[id] from scoped_docid where [objectid] = lower(@itemid)
	
	if (@scopedindex is null)  begin
		-- coalesce for the first record will have MAX = null, and then we add 1
		select @scopedindex=COALESCE(MAX(scopedocid),0)+1 from scoped_docid where scope = lower(@scope)

		insert into [scoped_docid] (scopeid ,scope,objectid, scopedocid ) values( lower(@scopeid), lower(@scope),LOWER( @itemid), @scopedindex)
		select @result = SCOPE_IDENTITY()
	end
	COMMIT	
	select @result as record,@scopedindex as docid	
END
GO

There is more to it than this, but you can check out the downloads for all the details.
Step 2
Create an SPDatabase object for this Database, see the Ton Stegeman post!

Step 3
Create a Document ID Provider that uses this SPDatabase and generates Document ID's based on some settings. What I did was generate the sequenced number in SQL and then format that in a method with the other variables. Generating a YEAR or DAY into a string is fairly easy.

Step 4
Create an Central Admin page to change the settings of our Document ID Provider ( see screenshot ).
You can use the SPFarm.Local.Properties to score your settings Farm Wide:

/// <summary>
        /// The default farm wide scope setting for this DocumentProvider
        /// </summary>
        public ProviderScope Scope {
            get {
                ProviderScope result = ProviderScope.Farm;
                try {
                    string setting = Settings.GetFarmSetting("CustomDocumentIDProvider.Scope");
                    if (!string.IsNullOrEmpty(setting))
                        result = (ProviderScope)Enum.Parse(typeof(ProviderScope), setting);
                }
                catch (Exception exc) {
                        LogException(exc);
                }
                return result;
            }
            set {
                Settings.SetFarmSetting("CustomDocumentIDProvider.Scope", value.ToString());
            }
        }


The scope:

/// <summary>
/// Scopes for the Document ID Provider
/// </summary>
public enum ProviderScope {
	/// <summary>Farm wide scope</summary>
        Farm=1,
        /// <summary>Webapplication scope</summary>
        Webapplication = 2,
        /// <summary>SPSite/Site collection scope</summary>
        SiteCollection = 3,
        /// <summary>Site/Subweb (SPWeb) scope</summary>
        Site = 4,
        /// <summary>List scope</summary>
        List = 5,
        /// <summary>No scope</summary>
        None = 100
}

Downloads
Download solution
Download sources

How to use the solution

 

(Crosspost of: http://stefvanhooijdonk.com/2010/06/21/document-id-provider-the-last-one )

Share:

Stef van Hooijdonk schreef

Comments (0)

Stef van Hooijdonk

Eerste Tam Tam SharePoint 2010 portal live!

14

Jun

Tam Tam werkt sinds het begin van dit jaar aan een groot aantal SharePoint 2010 projecten, en afgelopen week is de eerste "2010" portal daadwerkelijk live gegaan!

Het betreft een omgeving voor de Solimas Groep (het overkoepelende concern voor de werkmaatschappijen: Agile Software, InfraControl en GroeneIT) waarin alle documenten met betrekking op klanten en leveranciers worden gedeeld en bovendien alle werknemers worden voorzien van in/extern nieuws, de laatste dollarkoers, informatie over collega’s en een samenwerkomgeving per afdeling. Na het beschikbaar komen van de definitieve SharePoint release in mei kon gestart worden met het inplannen van de uiteindelijke configuratie van de portal, waarvan het exacte ontwerp al compleet op de plank lag. Inmiddels is de volledige omgeving in een tijd van enkele dagen geconfigureerd. De komende weken wordt nog gewerkt aan het customizen van het grafisch ontwerp en de geautomatiseerde migratie van de duizenden voorstellen en contracten uit de oude klantomgeving, maar nu al kunnen de Solimas Groep werknemers aan de slag op hun nieuwe portal.

Kenmerkend voor dit project is dat er een aantal complexe features gerealiseerd zijn die in voorgaande versies van SharePoint een flinke dosis maatwerk hadden gevergd, maar nu met uitsluitend configuratie van nieuwe SharePoint 2010 mogelijkheden zijn opgeleverd:

  • Klantdossiers bestaan uit “Documens sets” waardoor alle documenten in een klantdossier automatisch de kenmerken van de klant overnemen zodat ze ook per stuk vindbaar zijn op bijvoorbeeld accountnaam. Het werken met document sets in dit project combineert de voordelen van het werken met slechts 1 documentbibliotheek (eenvoudig weergaves wijzigen en toevoegen voor alle dossiers, geen groot aantal bijna lege subsites) met de voordelen van een afgescheiden onderdeel per klant (elk dossier heeft een eigen voorblad met daarop de klantkenmerken en een overzicht over alle documenten).
  • Klantdossiers worden gekoppeld aan de accounts in het bestaande Microsoft Dynamics CRM systeem van de Solimas Groep. Deze “Business Connectivity Services” koppeling is tot stand gebracht door configuratie met SharePoint Designer en levert een eenvoudige gebruikersinterface op waarin de werknemers op verschillende wijzen kunnen filteren om zo snel het juiste account te kunnen koppelen. Middels een kleine (SharePoint Designer) workflow krijgt klantdossier automatisch de naam van het gekoppelde account zodat de juiste CRM naamgeving consequent wordt gebruikt in alle systemen met klantdata.
  • De documenten die toegevoegd worden aan de klantdossiers worden voorzien van een in CRM gegenereerd opportunity-ID. Ook die koppeling is via SharePoint Designer geconfigureerd en wordt in 2 stappen door de gebruiker doorlopen: eerst zoekt hij het betreffende account en vervolgens kiest hij uit de lijst met opportunities die voor die klant lopen of hebben gelopen waarbij de meest recente uiteraard bovenaan staan. Dit CRM-nummer wordt ook weer automatisch toegevoegd aan de naam van het document zodat iedereen altijd een compleet overzicht heeft welke voorstellen en contracten zijn gemaakt binnen een opportunity.
  • Aan elk document worden via de “term store” een aantal trefwoorden toegevoegd die uit een centrale taxomomie met business units, projectsoorten en contractvormen worden gekozen.
  • Via de nieuwe “metadatanavigatie” kan eenvoudig door het alfabet geklikt worden om zo snel het dossier van een van de honderden klanten te vinden. Ook kan op de trefwoorden uit de boomstructuur van de term store geklikt worden om zo uit alle klantdossiers de eerder gemaakte voorstellen en calculaties voor een bepaald type project of contract naar boven te halen.
  • Zoeken van personen en het presenteren van het profiel van een gevonden collega heeft een ware evolutiestap ondergaan en hebben we in dit project zonder enige maatwerkaanpassing kunnen implementeren.

Al met al is dit project het eerste bewijs voor wat we bij de presentatie van SharePoint 2010 in oktober in Las Vegas al vermoedden: meer functionaliteit die gebruiksvriendelijker wordt gepresenteerd wordt mogelijk met veel minder maatwerk. Projecten als deze kunnen zich meer focussen op details die van belang zijn voor de organisatie en worden in veel mindere mate gedicteerd door beperkte of dure technische mogelijkheden.

Solimas Groep: van harte gefeliciteerd met jullie nieuwe portal, en bedankt voor het gestelde vertrouwen in Tam Tam en in Microsoft, nodig om al in zeer vroeg stadium te besluiten om dit project aan te durven op een nieuw platform dat ten tijde van die beslissing nog nauwelijks in Beta-fase was beland!

Maurice Bakker schreef

Comments (1)

Maurice Bakker

SP2010 and LinkedIn working together

24

Mar

Based on an oauth example over at http://developer.linkedin.com I created a webpart for the MySite Host homepage and activity page. Here a SP2010 user can authorize SP2010 to use the LinkedIn Api on his or hers behalf.

sp2010-linkedin-webpart-networkupdates

Read more: http://stefvanhooijdonk.com/2010/03/22/sp2010-and-linkedin-workin-together/

Stef van Hooijdonk schreef

Comments (0)

Stef van Hooijdonk

SharePoint 2010 Profile Sync

05

Mar

During the rebuild of my Dev Environment with SP2010 (the RC version) I was unable to get the Profile Sync service to work with the local domain. “Starting” was all it did until if finally un-provisioned itself to Stopped.

 

Read more: StefvanHooijdonk.com

Stef van Hooijdonk schreef

Comments (0)

Stef van Hooijdonk

Power of PowerShell and the SharePoint Snap-in

05

Mar

Recently I started to look into some more detail at PowerShell and the SharePoint 2010 Snap-in. As a small exercise I wanted to create something (somewhat) usefull.

I came up with a small site structure install script for SP2010.

Read more: http://stefvanhooijdonk.com/2010/03/02/power-of-powershell-and-the-sharepoint-snap-in/

Stef van Hooijdonk schreef

Comments (0)

Stef van Hooijdonk

New sample project for SP2010 Word Automation: UI

05

Mar

I've published a new sample project for the SP2010 Word Automation project on CodePlex. This sample will add a Ribbon button to document libraries enabling users to convert one or more documents directly from the UI. Read more on my personal blog here

Peter Gerritsen schreef

Comments (0)

Peter Gerritsen

2 new worflow activities added to SP2010 Word Automation

05

Mar

I've added 2 new custom workflow activities for Word Automation services to my codeplex project. You can read more about it on my personal blog in this post

Peter Gerritsen schreef

Comments (0)

Peter Gerritsen

SP2010 installation – error creating configuration database

05

Mar

When I tried to install the new RC of SharePoint 2010 on my machine, I got an “Error creating configuration database” message. When I went to the installation log I found a “User cannot be found” error. The cause was that the configuration wizard could not find the AD controller, which was easily solved by opening a VPN connection as I was working from home.

Share:

Peter Gerritsen schreef

Comments (0)

Peter Gerritsen

SPDisposeCheck and SharePoint 2010

24

Feb

Did you know the SPDisposeCheck tool?

Well on the product blog is a great post on Disposing and SP2010. named “SharePoint 2007/2010 ‘Do Not Dispose Guidance’

And even more usefull: SPDisposeCheck using Static Analysis in TFS ( 2010 )

You can download SPDisposeCheck as FxCop Ruleset here.

Cross post of: http://stefvanhooijdonk.com/2010/02/24/spdisposecheck-and-sharepoint-2010/

Stef van Hooijdonk schreef

Comments (0)

Stef van Hooijdonk

SharePoint 2010 on your Windows 7 Series phone

22

Feb

Daniel found this nice screenshot/mockup of windows 7 phone series showing the Office (2010) hub . Including SharePoint ( SP2010) tab.

Via Daniel;

(Cross post of: http://stefvanhooijdonk.com/2010/02/22/sharepoint-2010-on-your-windows-7-series-phone/ )

Stef van Hooijdonk schreef

Comments (0)

Stef van Hooijdonk