Nick Swan's SharePoint Blog

a day in the life of a Sharepoint and .NET guy!

My Links

News




Post Categories

Archives

Blog Stats

Blogroll

Books

VB-tech website

VB-tech work

Xbox

Tuesday, March 20, 2007 #

If you are reading this...

Then you are missing out on content on my new blog!

The new blog url is:

http://sharepointnick.com/blog/default.aspx

And the new RSS feed you need to subscribe to is:

http://feeds.feedburner.com/sharepointnick

See you on the other side!

posted @ 9:47 PM | Feedback (0)

Sunday, March 11, 2007 #

SharePointNick.com wiki

One of the reason I wanted to run my new blog/site on WSS 3.0 was so I could create a wiki site. I'm always reading great blog posts and 'how-to' articles, and even though I link to some of them here, I often struggle to find them just when I need to. So the aim of the SharePointNick.com wiki is for me to bookmark and categorize articles/tools/blog posts, that I find interesting, I want my colleagues to know about at Sword UK, and if they help you as well, then great! Here's the link:

http://sharepointnick.com/wiki/Wiki%20Pages/Home.aspx

posted @ 12:36 PM | Feedback (0)

Arrived in Seattle

I arrived in Seattle yesterday ready for the MVP summit. This is the first one I'm attending and I'm really excited about it. I've been swapping emails with many of the other SharePoint MVPs for around 12 months now and it'll be great to put faces to names. Most of all I'm looking forward to meeting Todd. We've been working on BDC Meta Man for around 8 months now I reckon, and have only spoken via messenger and phone.

I managed to stay awake the entire flight yesterday and the plan was to stay up till 10pm Seattle time but I gave up around 8pm (5am UK time). So I've ended up waking up at 5am local time which means I can spend some time working before getting breakfast. Yes I am here a couple of days early before the summit actually starts! But I thought it'd give me a little time to get used to the timezone change plus most of the other SharePoint MVPs are getting here on Sunday anyway so we'll be going out tonight. Hopefully I'll get lots of photo's up. Most the SharePoint MVPs are staying at the Crowne Plaza. The hotel is great and I've got a room on theh 18th floor which gives some interesting views!

posted @ 12:31 PM | Feedback (0)

Friday, March 09, 2007 #

SharePointNick.com

www.sharepointnick.com

This will be the new site very soon!

Make sure you are using the feedburner RSS feed and the move will be painless for you! Here it is:

http://feeds.feedburner.com/Vb-techWeblog

There's some 600 people that aren't using this so you better all update it now!

posted @ 8:55 PM | Feedback (0)

Multiple SharePoint 2007 sites running off Forms Authentication

Whether this was possible had me puzzled for a little while.

The scenario is, you want to run two WSS 3.0 (or MOSS 2007) sites of Forms Authentication, but they have different set of users and roles each. This could be typical in a hosted environment I guess.

The seperate WSS 3.0 sites and web applications themselves weren't a problem because you can put seperate connection strings, roles, and aspnetdb application names in each web.config. It was how to get Central Administration to recognise 2 seperate FBA applications so you could set the site collection administrators. I've already done plenty of FBA stuff with ASP.NET so thankfully this isn't new to me like it might be many SP administrators. Here's the stuff you need to put in central admin to get it working.

<connectionStrings>
    <add name="FBA1ConnString" connectionString="server=NickServer;database=AspNetDB;uid=sa;pwd=*****;" providerName="System.Data.SqlClient" />
    <add name="FBA2ConnString" connectionString="server=NickServer;database=AspNetDB;uid=sa;pwd=*****;" providerName="System.Data.SqlClient" />
</connectionStrings>

Having just looked at this, if you were more clever than me you could in effect just have one connection string as we're looking at the same aspnetdb

<membership defaultProvider="FBA1AspNetSqlMembershipProvider">
    <providers>
        <add name="FBA1AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        connectionStringName="FBA1ConnString"
        enablePasswordRetrieval="false"
        enablePasswordReset="true"
        requiresQuestionAndAnswer="false"
        applicationName="FBA1"
        requiresUniqueEmail="false"
        passwordFormat="Hashed"
        maxInvalidPasswordAttempts="5"
        minRequiredPasswordLength="1"
        minRequiredNonalphanumericCharacters="0"
        passwordAttemptWindow="10"
        passwordStrengthRegularExpression=""
        />

        <add name="FBA2AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        connectionStringName="FBA2ConnString"
        enablePasswordRetrieval="false"
        enablePasswordReset="true"
        requiresQuestionAndAnswer="false"
        applicationName="FBA2"
        requiresUniqueEmail="false"
        passwordFormat="Hashed"
        maxInvalidPasswordAttempts="5"
        minRequiredPasswordLength="1"
        minRequiredNonalphanumericCharacters="0"
        passwordAttemptWindow="10"
        passwordStrengthRegularExpression=""
        />

    </providers>

</membership>

<!-- role provider -->
<roleManager enabled="true" defaultProvider="AspNetWindowsTokenRoleProvider">
    <providers>
        <add name="FBA1AspNetSqlRoleProvider"
        type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        connectionStringName="FBA1ConnString"
        applicationName="/"
        />
        <add name="FBA2AspNetSqlRoleProvider"
        type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
        connectionStringName="FBA2ConnString"
        applicationName="/"
        />
    </providers>
</roleManager>

For this to all make sense here are some articles I suggest reading:

http://www.wildwires.com/Blog/PermaLink,guid,2dc7ea3d-c892-4baa-b990-671e0c2ab673.aspx

http://www.chandima.net/Blog/Lists/Posts/Post.aspx?ID=6

http://www.andrewconnell.com/blog/articles/HowToConfigPublishingSiteWithDualAuthProvidersAndAnonAccess.aspx

My very old post on setting up FBA:
http://weblog.vb-tech.com/nick/archive/2006/06/14/1617.aspx

posted @ 11:03 AM | Feedback (1)

SharePoint Developers/Architects wanted

Sword UK, the company I work for, are expanding quickly with lots of new projects coming in. We're looking for people to work on both the SharePoint dev and administration side of things. If you've got SP 2003 or good ASP.NET experience we'll get you trained up to 2007. If you are intested in getting involved in areas that are new to you such as training or product development we can also help with that.

Chance to attend conferences such as TechEd both in Europe and in US, plus you get to work with me! (ok I know the conference bit is much more exciting!)

Most work is based around the M25, but there is also plenty of work outside of London.

If you're interested drop me a note at nick.swan@sword-uk.com or give me a ring on 07725 960903

[no agencies!]

posted @ 9:35 AM | Feedback (0)

Monday, March 05, 2007 #

Detailed steps to setup FBA for MOSS 2007 including getting My Sites to work!

I remember back in the day when RTM of SharePoint was just a twinkle in the SharePoint teams eye, I blogged one of the first walk throughs of how to get FBA working for SharePoint 2007. Thankfully over time many people have done a much better job of detailing the steps, and the best one to date is without doubt Dan Attis. Many people have been struggling with My Sites and FBA and pondering if it was even possible. Well Dan the Man has a great walk through of how to get it all working!

Part One is the basics.

Part Two explains what you have to do to get MySite working. 

Thanks to Stacy who pointed Dans posts my way

posted @ 9:03 PM | Feedback (1)

Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!)

Hopefully you've walked through the first article and successfully created your InfoPath 2007 forms and the Visual Studio project needed to create our simple sequential worklow. Now we need to set about deploying it. First let's look at feaure.xml in DeploymentFiles\FeatureFiles. Copy and paste the following xml into that file:

<?xml version="1.0" encoding="utf-8"?>
<Feature Id="1E6D3BDD-9877-41ec-826C-EDE276EB560B" Title="Nicks Workflow" Description="Nicks workflow the same as the simple sequential one."
    Version="12.0.0.0"
    Scope="Site"
    ReceiverAssembly="Microsoft.Office.Workflow.Feature, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"
    ReceiverClass="Microsoft.Office.Workflow.Feature.WorkflowFeatureReceiver"
    xmlns="http://schemas.microsoft.com/sharepoint/">
    <ElementManifests>
        <ElementManifest Location="workflow.xml" />
    </ElementManifests>
    <Properties>
        <Property Key="GloballyAvailable" Value="true" />

        <!-- Value for RegisterForms key indicates the path to the forms relative to feature file location -->
        <!-- if you don't have forms, use *.xsn -->
        <Property Key="RegisterForms" Value="*.xsn" />
    </Properties>
</Feature>

Here you can change the name of your workflow Title and Description. It would also be a good idea to generate your own guid id and add it as the Feature Id.

The next file we need to look at is workflow.xml. Copy and paste the following xml into that file.

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
    <Workflow Name="Nicks Sequential Workflow." Description="Simple workflow that creates a review task and waits for the user to complete it."
        Id="48500BEB-D1BE-4ec4-8D21-5DEF76BEEDA8"
        CodeBesideClass="NicksWorkflow.Workflow1"
        CodeBesideAssembly="NicksWorkflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=0ac2d69683afd41e"
        TaskListContentTypeId="0x01080100C9C9515DE4E24001905074F980F93160"
        AssociationUrl="_layouts/CstWrkflIP.aspx"
        InstantiationUrl="_layouts/IniWrkflIP.aspx"
        ModificationUrl="_layouts/ModWrkflIP.aspx">

    <Categories/>
    <!-- Tags to specify InfoPath forms for the workflow; delete tags for forms that you do not have -->
        <MetaData>
            <Instantiation_FormURN>urn:schemas-microsoft-com:office:infopath:DemoInitiation:-myXSD-2007-03-03T23-40-46</Instantiation_FormURN>
            <Association_FormURN>urn:schemas-microsoft-com:office:infopath:DemoInitiation:-myXSD-2007-03-03T23-40-46</Association_FormURN>
            <Task0_FormURN>urn:schemas-microsoft-com:office:infopath:TaskEdit:-myXSD-2007-03-03T23-45-45</Task0_FormURN>

            <StatusPageUrl>_layouts/WrkStat.aspx</StatusPageUrl>
        </MetaData>
    </Workflow>
</Elements>

Again you are free to change the title and description attibutes here, and also again it's best to generate your own guid id for the id attribute. The code beside class is the fully qualified name of your workflow class, eg namespace.classname. The CodeBesideAssembly is made up of the name of your dll (you can often take this as being the project name), the assembly version which is set in the Properties\AssemblyInfo.cs file. To get the public key value of our assembly we need to open a Visual Studio 2005 Command Prompt. This can be found via the start menu by going Start -> Program Files -> Visual Studio 2005 -> Visual Studio tools -> Visual Studio 2005 Command Prompt

In the command prompt type : sn -T "path to your workflow dll"

The only other parts you need to worry about for this workflow are the formURN's. These are used to identify exactly which InfoPath form should be used at each point. You can find these values by opening your published InfoPath 2007 forms in design mode (right click on them in explorer and chose design), then from the main menu go File -> Properties, and the value will be in the ID field:

We are only going to build and deploy our workflow in debug mode so we don't need to worry about the files in the Production Folder.

When we do a Re-Build of our solution the PostBuildActions.bat file will be executed. From a new project however in the post build actions of the project a parameter of NODEPLOY is passed to it so our workflow feature is not deploy. To change it so our workflow is deployed do the following steps:

1, Right click on your workflow project and chose Properties

2, Select the Build Events tab from the project properties screen.

3, In the textbox for the "Post-build event command line:" the last parameter of the line will be NODEPLOY. Change this to simply DEPLOY

And that is it. To build and deploy our solution simply rebuild it. Generally this can be done by pressing F6 or going Build -> Rebuild Solution from the main menu.

You should get something similar to the following text in the output window. If you get an errors detailed here hopefully there should also be a hint of how to fix it. Something else to check before trying to bind your new workflow to a document library is that the correct files have been deployed to the 12 hive. Look in ..\12\TEMPLATE\FEATURES\NicksWorkflow - or whatever you called your workflow and you should see feature.xml, workflow.xml, DemoInitiation.xsn and TaskEdit.xsn.

If the deploy seemed to run ok and you have all the files in your Feature folder, go and try your workflow out! Good luck!

I hope all the above makes sense. As with the previous workflow article this is my own attempt at explaining quite a tricky process (and very annoying if you get wrong and can't figure out why! :-) ) If you spot any inaccuracies please let me know in the comments.

posted @ 8:51 PM | Feedback (17)

Wednesday, February 28, 2007 #

BDC Meta Man - Version 1.2.0.2 Beta

We've put a new release of BDC Meta Man out late last night. This one is a beta at the moment as we wanted to give people a chance to test things out. If you have any trouble with this beta you'll be able to revert to 1.2.0.1 no problem.

Here are a details from the release notes:

New Features Added:

Developer and Professional Versions:

- Actions now appear inside BDC Web Parts in the same order they appear inside the Actions list on the Actions tab.

Previously, the display order of Actions in BDC Web Parts, was not always consistent with the order they were displayed inside the BDC Meta Man.

- Added support for tables with String identifiers.

- Added support for tables with Guid identifiers.

- Added support for tables with spaces in their names.

- Added support for tables with columns that have spaces in their names.

Professional Version Only:

- A custom Action builder has been added to the application to allow the creation of custom Actions. The custom actions can accept up to three parameters.

- Added the ability to set the Image Url for both the predefined Actions that come with BDC Meta Man, and custom Actions you create.

- Added two more parameters to the Actions tab to allow actions to accept up to three parameters.

Bug fixes (Developer and Professional Versions)

- Fixed the bug where an exception would occure when you clicked cancel on the Action Picker, without selecting one of the predefined actions.

 

If you have the professional version you'll also be able to create associations between entities with primary keys of guid or string type, and tables with spaces between the table names and column names.

Please leave us any feedback, whether that it works great, or you have bugs. Many thanks!

posted @ 4:36 AM | Feedback (1)

Sunday, February 25, 2007 #

SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!)

I have been amazed at how many hits and questions the 'how-to' article I posted on creating a SharePoint 2007 workflow with Visual Studio 2005 and InfoPath 2007 got. That article was based on Beta2 of SharePoint 2007, and although most of the steps are still the same, I decided to rewrite the article now that RTM is out. There were so many questions on the previous post that it was difficult for me to answer them all, so I've got to thank other people who tried out the workflow and got it to work for coming along and helping others. At the end of this article I've a link to forum post where I think we can put questions about this guide. That way people can sign up to alerts and we can hopefully get peoples questions answered in a much more organised way. So here it is, buckle down and good luck...

[after thought - this post and capturing all the images has taken almost 5 hours. If you are reposting it somewhere else (ie stealing it!), please at least give a link back! And if you like the post also please give me a link ;-) ]

Getting Started

The first thing you need to get right is your development environment. I'm working on Virtual PC 2007 which has Windows 2003 server and MOSS installed on the image. This image is also my development environment so I've installed Office 2007 Pro Plus, and Visual Studio 2005 directly onto Windows Server 2003.

Once Visual Studio 2005 is on we need to install the necessary components to be able to work with Windows Workflow Foundation. Download and install the Visual Studio 2005 Extensions for .NET Framework 3.0.

Once you have downloaded and installed those components you'll be able to create Workflow type projects but we need the SharePoint workflow templates. To get these, download and install the Microsoft Office SharePoint Server 2007 SDK which also includes the Enterprise Starter Kit.

Now that we have these two things installed in the Create New Project box in VS 2005 you should be able to create a SharePoint Sequential Workflow and a SharePoint State Machine Workflow.

So that's the setup done, now lets just recap what it is we'd like our workflow to do. This is copied from the original workflow article:

We want to allow our workflow to be associated with a list or document library. When a document is created or changed (this is a setting chosen upon binding the workflow to the list/library), a person specified will have a task created for them, with some pre-defined instructions and comments. When clicking the task the user will have a designed form where they will have instructions present, and can decide whether to complete the task with a checkbox.

From the above we’re going to need 2 InfoPath forms. Number 1 is used when binding our workflow to a list/library where we’ll enter the user who’ll get the task, and a few instructions and a comment. The second form is when the user clicks on the task. In this form they can add comments and click a checkbox to complete the workflow.

This project is basically the HelloWorldSequential workflow from the ECM starter kit, but it's a nice walk through of how to put it together yourself!

Lets go and create our workflow project in Visual Studio 2005. We're going to be using a sequential workflow template, and lets give it a name of NicksWorkflow

Once the project is created you'll see in the Solution Explorer that there's a new folder called Deployment Files. This is where you'll now find feature.xml and workflow.xml. We'll dig into how to deploy our workflow in the next blog post so don't worry about these for now.

As with the previous article, before we start writing any code we want to create our two InfoPath 2007 forms. We want to do it this way as we're going to generate a C# class from one of our forms to help with the passing of data to and from it. The first form we are going to create is the initiation form. This captures information such as who we want the task to be assigned to, a field for instructions to them and a comments textbox.

Initiation Form

1, Open up InfoPath 2007 and from the first form select 'Design a form template...'

2, Click OK to create a blank form template...

3, From the top menu bar click Insert->Layout Table... and then select your table to have 2 columns and 4 rows...

4, Add three textboxes and a button to the columns in the right, and a description in the cells to the left of each textbox. We need to also give each textbox a proper name, do this by double clicking on it, and entering the new name into Field Name

Once you've renamed your textboxes and given the button a Label value of submit, your InfoPath form should look something like this:

5, Data from InfoPath forms is represented by XML. To make it easier for us to get our hands on the XML data we require we can give the XmlElement that holds these control values a better name. From the Design Tasks toolbar click on Data Source...

Double click on myFields

And in the following form that opens up enter InitForm as the Name value...

Click OK to close that.

6, Now we need to configure what happens when people click on the submit button. Double click on the submit button to bring up it's properties, from the General tab click on the Rules button

In the following form, click Add to create a new rule. Click 'Add Action', and from the following form chose 'Submit using a data connection' from the drop down, then click the Add button just below:

In the next wizzard chose the following options to submit your data:

and then the hosting environment as the destination

Leave the name as Submit and click Finish. And then OK on the 'Add Action Form'

Now we want to add another action, so back in the Rule form click 'Add Action...' This time the action 'Close this form' and make sure the checkbox is not selected...

Clicking OK takes us back to our Rules form. That's the two actions we want to add for our Submit button. With them both together they should look like this:

Click OK to close this form.

7, Now we need to ensure our form can be viewed in a browser as this is how InitForm will be used when setting up a workflow.

Go back to our Design Tasks toolbar, and click 'Design Checker'

From the Design Checker pane chose 'Change Compatibility Settings...'

Click the checkbox to allow our form to be opened in a browser, also enter the url for MOSS 2007 to help verify compatibility...

While you are in this form, click on the Browser category, and ensure the language selected is infact a language pack that you have installed on your MOSS server...

One final step is to go to the 'Security and Trust' category. In here untick to automatically determine the level of security, and select Domain...

Click OK to close the 'Form Options' form. Now we need to save our form. Save it directly to the C:\ as DemoInitiation.xsn. Once saved we can publish it by going File->Publish, chose to publish it 'To a network location' and then chose the location of your VS 2005 project, and the "Deployment Files/Feature Files" folder.

Click Next, remove the path as the alternate access location. You will get a warning when clicking next on that form but that is ok. If you do not remove the alternate access path you will have problems when publishing your form to work with workflow. Finally Publish and Close.

When we submit our forum to SharePoint we need to be able to get the data from the submitted form to be able to use in our workflow. To help do this we can generate a class using xsd.exe based off the form schema file. First we need to save our InfoPath form as Source Files. File -> Save as Source Files. Browse to the location you want to save the file (c: is a nice easy place), and click OK. By default the source files are saved as filename myschema.xsd. Once saved close InfoPath.

Now open up a Visual Studio 2005 command prompt and navigate to where you saved myschema.xsd. From the prompt type xsd myschema.xsd /c

this generates a c# class file called myschema.cs. Rename the file to InitForm.cs, and add it to you VS 2005 workflow project. If you take a look inside the classes code you’ll see the name of the class is the same that we gave to the forms field collection.

Edit Task Form

Now we need to jump back into InfoPath 2007 so we can create our form that enables users to edit the task they get assigned to complete the workflow.

1, Open InfoPath 2007 again and create a blank form as we did before. On this form we’re going to want an instructions textbox where we’ll place the instructions entered when we bound the workflow to a list/library, a checkbox to check to say the workflow is complete, and an ok button. Lay it all out and rename the fields to something like below...


Underneath the isFinished tooltip is simply some text of 'Completed'.

2, Add the same rules to the OK button as you did to the submit button for the DemoInitiation form (ie submit to a hosted environment, and then close).

3, When this Edit form opens we’re going to want to pass some data to it (ie the instructions), we do this by creating a task schema and adding it as a secondary data source.

Open up notepad and add the following:
<z:row xmlns:z="#RowsetSchema" />
In this file we need to define every property that we are going to pass to the Task Edit form. To do this, add an attribute comprised of the prefix ows_ and the name of the task property. Set the attribute equal to an empty string. So to pass the instructions to the Task Edit form that were added when we bound the workflow to the list/library we add the following attribute:
ows_instruction=””

So your finished notepad text should be:
<z:row xmlns:z="#RowsetSchema" ows_instructions="" />

It doesn't matter where you save the file, just make sure it's called ItemMetadata.xml (yes it does matter about the case with this).

4, Now we need to add the task schema to our Edit Task form as a secondary data source. Back in InfoPath, in the Design Tasks pane select Data Source, and then click 'Manage Data Connection'.

In the form that opens you'll see there is a Submit data connection already. On the form Click Add to create a new data connection. On the wizzard form that opens click so the new connection receives data...

Select XML Document as the data source to receive data from...

Then browse and select the ItemMetadata.xml file you created in Notepad in step 3...

Leave the option selected to include this file as a data source...

Click Next, and then Finish. The data connections form should now look as below:

Click Close to get that job done!

5, Now we need to bind the data that we are receiving from our new data connection to the necessary fields. Double click the instructions textbox and on the Data tab, under Default Value, click the formula button (underlined in red)...

On the Insert Formula dialog box, click Insert a Field or Group. In the Select a Field or Group dialog box, select your ItemMetadata data connection from the drop down menu. Select the ows_MetaInfo_instructions element.

Click OK. On the Insert Formula dialog box, click OK. On the Properties dialog box, click OK.

6, Now we need to do the same things as we did with the initiation form, set the form as browser enabled also entering the url of our MOSS server, check the language setting of the form, and also set the Trust Level as Domain.

Save the form to c:\ again (or whever you saved it), and publish it to your VS workflow project, "Deployment Files\Feature Files" directory again.

And that's it for InfoPath, our forms are created and ready to use!!!

Back to Visual Studio 2005

Now we can get down to some coding! In the solution explorer double click on Workflow1.cs and up will open the workflow designer view. If you open up the toolbox you'll see three new groups of components, SharePoint - Workflow Tasks, SharePoint - Workflow, and Windows Workflow.

As you can see on the Workflow1.cs design surface it already creates the first workflow step for us with a onWorkFlowActivated action. This will always be the first Workflow action of any workflow. Below this action is an arrow and a kind of stop sign. We can drag and drop any new workflow actions from the tool box and place them on the arrow. Before we do that though there are a few properties we can check before we get going. If you go into the code view of Workflow1.cs you’ll see

public sealed partial class Workflow1: SharePointSequentialWorkflowActivity
{
    public Workflow1()
    {
       InitializeComponent();
    }

    public Guid workflowId = default(System.Guid);
    public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties workflowProperties = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties();
}

This is all created for you because you used a template project. If you view the properties of work onWorkflowActivated1 you’ll see the following important properties set for you:
CorrelationToken : workflowToken
    OwnerActivityName : Workflow1
WorkflowProperties – expand this
    Name : Workflow1
    Path : workflowProperties – again this is a variable that was created for us and set from the code above.

We also get an event for this control. When this fires we’ll want to setup any initial variable values that are required for the workflow. Type into the Invoked space onWorkflowActivated and press enter. You’ll see it goes to the code view and creates our event handler for us with the correct interface. We’ll come back to this later.

Now to add our first workflow control. Now that the workflow has actually started the first thing we want to do is create a task for the person who’s been set to complete it. Remember we defined this when attaching the workflow to an actual list in SharePoint. To do this drag and drop a CreateTask control just below our onWorkflowActivated1 control.

We need to set a few properties for this control. First type in the Correlation Token as taskToken. Upon pressing enter you’ll see that you can expand this property to reveal OwnerActivityName which once again should be set as Workflow1. 
Next we’ll set the TaskId and TaskProperties which can be accomplished in a couple of ways. First method is to click on the default value of TaskId (0000–0000…. or something) and you’ll see three ellipses on a button appear. Click on this and it’ll open a dialogue box for you. Click on the ‘Bind to a new member’ tab and click the 'Create Field' radio button.

Click OK. In the propeties window of createTask1 you’ll see now that not only have 2 pairs of name and values gone into the TaskId property, but you can expand them out to set them seperately. Also if you switch to code view, you’ll see that a variable called createTask1_TaskId1 (the name that was entered in the 'new member name' textbox) has been added to our code for us.

Follow the same procedure for TaskProperties. Switch back to the code view again and you’ll see the variable created for us. If you go back to the createTask1 properties view and click the ellipses for TaskProperties again, you can see in the ‘Bind to an existing member’ that this property is bound to taskProps in our Workflow1 class. So as well as using this dialog box and the ‘Bind to a new member’ tab, we could have gone into our code view, created the createTask1_TaskId1 and createTask2_TaskProperties1 variables ourselves, and then used the Bind to an existing member view to set the values of the properties. Final thing to do is create the event that fires when this activity executes. In the Method Invoking field enter createTask and click enter. Again is creates our event handler and interface for us. Again we’ll come back to this is a little while. Finally we need to set the CorrelationToken as taskToken (just type it in). The same token name will be used in other task activities that we drag onto our workflow. Using the same token ensures we are working with the same task. Here is how the properties window for createTask1 should be looking:

Now that our task has been created for the assigned user, we need to add some waiting functionality to enable the workflow to wait for the task to be completed by the user. We do this using the While workflow component.

Drag and drop a While component from the Windows Workflow section in the toolbox between the createTask1 and the end of the workflow. In the properties window select Code Condition as the Condition property's value and then expand the field. Then type notFinished into the extra field presented and press enter. This will create an event handler for you in code where you check whether the While condition has been met (ie has the user completed their task).

Now we want to add an activity to the centre of our While loop. Here we’ll place an onTaskChanged. This basically means that the While loop will execute and check our code condition, every time our task is edited. It won’t be able to exit out of the While loop until our method notFinished returns false (which means it is finished!). Drag an onTaskChanged component and drop it in the middle of our While loop.

You’ll see in the properties window there are quite a few things we need to set:
AfterProperties = click the ellipses and bind to a new Field member
BeforeProperties = click the ellipses and bind to a new Field member
CorrelationToken = select taskToken from the drop down
Invoked = onTaskChanged. When you’ve typed it in press enter to create the event handler for you.
TaskId = click the ellipses and bind to the existing member called createTask1_TaskId1

The properties window for onTaskChanged should now look as below, make sure you set the Correlation Token:

The final component we want to add to our workflow is the CompleteTask activity. Drag and drop a CompleteTask component between the While component and the stop workflow activity. In the properties set the Correlation Token to taskToken from the drop down. Again with the TaskId click the elipses and bind it to createdTask1_TaskId1.

Now we’ve added all the components to our workflow. Our workflow designer should look as below:

 

Now we’ve got all our components added, and event handlers and methods created, we need to add some code to Workflow1.cs.
Right click on Workflow1.cs and click View Code. The first bit of code we need to add declares a few variables we are going to need in our workflow. Just above the onWorkflowActivated method add:

private String assignee = default(String);
private String instructions = default(String);
private String comments = default(String);

These three values are ones that we are going to get from our DemoInitiation form. These properties are passed to the workflow as an XML string represented by the InitiationData property of the SPWorkflowActivationProperties object. To access these properties we need to parse this XML string. This is where we make use of the generated class based on the schema of our initiation form that we did in step 4 and added to our project as InitForm.cs. To get these values add the following code to the onWorkflowActivated method:

workflowId = workflowProperties.WorkflowId;
XmlSerializer serializer = new         XmlSerializer(typeof(InitForm));
XmlTextReader reader = new XmlTextReader(new         System.IO.StringReader(workflowProperties.InitiationData));
InitForm initform = (InitForm) serializer.Deserialize(reader);
assignee = initform.assignee;
instructions = initform.instructions;
comments = initform.comments;

The next method we need to add some code to is createTask Method. Here we want to set some properties of a task as this method fires just before the task does actually get created. Here’s the code:

createTask1_TaskId1 = Guid.NewGuid();
createTask1_TaskProperties1.Title = "Demo Task";
createTask1_TaskProperties1.AssignedTo = assignee;
createTask1_TaskProperties1.Description = instructions;
createTask1_TaskProperties1.ExtendedProperties["comments"] = comments;
createTask1_TaskProperties1.ExtendedProperties["instructions"] = instructions;

as you can see there are a predefined properties such as Title and AssignedTo to use, and if there’s any other properties you want to name and create yourself you can use the ExtendedProperties. This is a hash table so you can name things as you like.

The final bit of code we need to add is probably the most complex to get our heads around. We need to add a private Boolean variable called isFinished. Place this just above the notFinished method:

private bool isFinished;

Now our While loop calls the notFinished method. One of the objects passed in is ConditionalEventArgs which has a property called result. If result is set to false, the while loop will end, if result is set to true, the while loop continues. As you should be able to work out, the variable above we created isFinished will be true once the task has been finished. Therefore we have to negate it to set it’s value to the ConditionalEventArgs result property. In the notFinished method type the following code:

e.Result = !isFinished;

The last thing we need to do is actually set isFinished when our task gets edited ie when onTaskChanged event files. In here we just need to parse out the isFinished value from our onTaskChanged1_AfterProperties1 object. At the code below to the onTaskChanged method:

isFinished = bool.Parse(onTaskChanged1_AfterProperties1.ExtendedProperties["isFinished"].ToString());

And that’s it. Build your solutions, and hopefully everything compiles succesfully. Now I was also going to include instructions on how to deploy this workflow, but I’m going to save that for a few days time.

If you find any errors in the post please let me know...

posted @ 7:27 PM | Feedback (27)

Saturday, February 24, 2007 #

PC Graphics Card problems

Anyone else seen these problems while playing BF2142? It happens during the game as well as in the menus:

 It seemed to only start happening after I installed company of heros, although I can't be sure!

Thanks for any help!

posted @ 10:19 PM | Feedback (3)

Thursday, February 22, 2007 #

Final 20 SharePoint 2007 application templates available

A day late on this one but just in case you haven't opened your RSS reader for the last 24 hours the final 20 application templates of the "Fantastic 40" have now been released! Full details on the SharePoint team blog:

http://blogs.msdn.com/sharepoint/archive/2007/02/21/completing-the-fantastic-40-20-remaining-application-templates-now-available-plus-more.aspx

Dustin Miller of SharePoint Experts fame is also hosting the templates for people to try out! Now you don't even have to download them yourself to see just how great they are! Here's the link to the hosted examples:

http://www.sharepointexperts.com/v3demo.htm

posted @ 4:40 PM | Feedback (0)

Wiki Wednesday - it's not just about Wiki's?

[written on the way home, posted the next evening]

I'm on the train home from Wiki Wednesday in London and although it was a great evening and I enjoyed almost all of it, I'm a little annoyed about a couple of the presentation. I went along with the intention of demonstrating wiki functionality in Windows SharePoint Services 3.0 which as time was running short I think I did ok with in a 5 minute slot. There were other presentation from other Wiki software, and people who are using wikis in an enterprise type environment.

What annoyed me was some guy from something called SMBlive who first of all claimed SharePoint was expensive while I was presenting, and then later claimed it wasn't a collaboration platform.

The SMBLive person got up and did a sales pitch saying they'd used the SharePoint platform, but scrapped it all and built a new UI on it for small businesses to use free of charge. Fair enough that's possible, after all the SharePoint UI doesn't float everyones boat. But claiming that in it's current state it wasn't a collaborative platform is a bit of a joke. And as for the free part, it's free for 2 users, with a 10 mb limit. So basically you can host one file with it as lets face it a word or powerpoint document can easily be over 10 mb these days. As soon as you want more space you have to pay for it, and more than two users, you need to pay £7.50 a month for each of them. Rather than this SMBLive Product why not just use Office Live? Apparently BT are investing lots of money into these SMBLive products, but I have to ask myself when was the last time BT managed to do anything worth while for collaboration and small businesses.

The most annoying part of it all was that the guy from SMBLive left as soon as he'd done his pitch, so I couldn't even discuss with him the points he'd made about SharePoint. Next time I should just shout out while he's presenting perhaps?

The last presentation I saw was by Barry Shrier. He decided that on a night called Wiki Wednesday he'd present about his new service called The Good Club.com (I'm not going to give it any link love!). At that point I decided to leave. I'm really sorry to the people I'd missed as I'm sure there were still lots of great presentation, and the initial ones were great as well, but there's only so many sales pitches I can take when it's supposed to be a community type evening.

Thanks to Goodman Jones who hosted the evening, and David Terrar who organised it all.

posted @ 4:11 PM | Feedback (2)

Tuesday, February 20, 2007 #

BDC Meta Man Podcast

I was interviewed by Michael Greth recently at the Berlin SharePoint Conference for his SharePointPodcast.de show. This is the first time I've appeared on a podcast! Quite an honor to be on the same show as Patrick Tisseghem as well. Usually SharePointPodcase.de is recorded in German (as is the intro in this show), but the actual interviews this time are in English. If you'd like to listen here's the link to the show:

http://blogs.mysharepoint.de/sharepointpodcast/archive/2007/02/19/SPPD064-SharePointPodcast.aspx

I'm on from 4 minutes 20 - 9 minutes 30

posted @ 2:21 PM | Feedback (0)

Monday, February 19, 2007 #

SharePoint 2007 books hitting the street!

The third SharePoint 2007 book is out now... Microsoft SharePoint: Building Office 2007 Solutions in C# by Scot Hillier. I've got my copy ordered!

Mike Walsh is keeping an up to date list of all the books out now, and coming in the future so keep an eye on his page:

http://www.asaris.de/sites/walsh/Lists/WSSv3%20FAQ/V%20Books.aspx

It's amazing to see the number of SharePoint v3 books coming out compared to v2! Now I've just got to speak to all the publishers to see if I can get free copies to give away at user group meetings! If anyone can sort that out for me drop me an email...

posted @ 4:12 AM | Feedback (2)

Saturday, February 17, 2007 #

Business Data Catalog and Guids as table primary keys

This one had me puzzled for a little while today. People have been asking us to get BDC Meta Man generating application definition files for tables with Guid primary key columns rather than integers for a while and so this weekend that was the task.

The first thing you have to get your head round is that you'll need a seperate finder and specific finder method for guid tables. With integer primary keys you can get away with just one method that has two method instances.

Second is more tricky! If you define your identifier and type descriptors as System.Guid your profile page will return the following error when executing the specific finder method:

Exception in BusinessDataWebPart.OnPreRender: System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

What you need to do however is define these as type System.String. Also do not put apostraphies around the parameter in the SQL statement as I did to start with, you'll get errors about key type conversion if you do that. Here's an example application definition file for a very simple table that has a guid as it's primary key:

 

<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<LobSystem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance " xsi:schemaLocation="http://schemas.microsoft.com/office/2006/03/BusinessDataCatalog BDCMetadata.XSD" xmlns=" http://schemas.microsoft.com/office/2006/03/BusinessDataCatalog" Type="Database" Version="1.0.0.0" Name="GuidTestLOBSystem">
 <Properties>
  <Property Name="WildcardCharacter" Type="System.String">%</Property>
 </Properties>
 <LobSystemInstances>
  <LobSystemInstance Name="GuidTestInstance">
   <Properties>
    <Property Name="DatabaseAccessProvider" Type="System.String">SqlServer</Property>
    <Property Name="AuthenticationMode" Type="System.String ">PassThrough</Property>
    <Property Name="RdbConnection Data Source" Type="System.String">localhost</Property>
    <Property Name="RdbConnection Initial Catalog" Type=" System.String">GuidTest</Property>
    <Property Name="RdbConnection Integrated Security" Type="System.String">SSPI</Property>
    <Property Name="RdbConnection Pooling" Type=" System.String">false</Property>
   </Properties>
  </LobSystemInstance>
 </LobSystemInstances>
 <Entities>
  <Entity EstimatedInstanceCount="0" Name=" dbo.Customers">
   <Identifiers>
    <Identifier Name="CustomerId" TypeName="System.String" />
   </Identifiers>
   <Methods>
    <Method Name="Getdbo.Customers ">
     <Properties>
      <Property Name="RdbCommandText" Type="System.String">Select CustomerId,CustomerName From dbo.Customers</Property>
      <Property Name="RdbCommandType" Type=" System.Data.CommandType">Text</Property>
     </Properties>
     <Parameters>
      <Parameter Direction="Return" Name="dbo.Customers">
       <TypeDescriptor TypeName=" System.Data.IDataReader, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="dbo.CustomersDataReader" IsCollection="true">
        <TypeDescriptors>
         <TypeDescriptor TypeName="System.Data.IDataRecord, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="dbo.CustomersDataRecord">
          <TypeDescriptors>
           <TypeDescriptor TypeName="System.String" IdentifierName="CustomerId" Name="CustomerId" />
           <TypeDescriptor TypeName="System.String" Name="CustomerName" />
          </TypeDescriptors>
         </TypeDescriptor>
        </TypeDescriptors>
       </TypeDescriptor>
      </Parameter>
     </Parameters>
     <MethodInstances>
      <MethodInstance Name="dbo.CustomersFinder" Type="Finder" ReturnParameterName="dbo.Customers" ReturnTypeDescriptorName="dbo.CustomersDataReader" ReturnTypeDescriptorLevel="0" />
     </MethodInstances>
    </Method>
    <Method Name="dbo.CustomersSpecificFinder">
     <Properties>
      <Property Name="RdbCommandText" Type="System.String ">Select CustomerId,CustomerName From dbo.Customers Where (CustomerId=@CustomerId)</Property>
      <Property Name="RdbCommandType" Type=" System.Data.CommandType">Text</Property>
     </Properties>
     <FilterDescriptors>
      <FilterDescriptor Type="Comparison" Name="CustomerId" />
     </FilterDescriptors>
     <Parameters>
      <Parameter Direction="In" Name="@CustomerId">
       <TypeDescriptor TypeName="System.String" IdentifierName="CustomerId" AssociatedFilter="CustomerId" Name="CustomerId" />
      </Parameter>
      <Parameter Direction="Return" Name="dbo.Customers">
       <TypeDescriptor TypeName="System.Data.IDataReader, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name=" dbo.CustomersDataReader" IsCollection="true">
        <TypeDescriptors>
         <TypeDescriptor TypeName="System.Data.IDataRecord, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name=" dbo.CustomersDataRecord">
          <TypeDescriptors>
           <TypeDescriptor TypeName="System.String" IdentifierName="CustomerId" Name="CustomerId" />
           <TypeDescriptor TypeName=" System.String" Name="CustomerName" />
          </TypeDescriptors>
         </TypeDescriptor>
        </TypeDescriptors>
       </TypeDescriptor>
      </Parameter>
     </Parameters>
     <MethodInstances>
      <MethodInstance Name="dbo.CustomersSpecificFinder" Type="SpecificFinder" ReturnParameterName="dbo.Customers" ReturnTypeDescriptorName=" dbo.CustomersDataReader" ReturnTypeDescriptorLevel="0" />
     </MethodInstances>
    </Method>
   </Methods>
  </Entity>
 </Entities>
</LobSystem>

 

Needless to say this functionality will be coming to generate this all automatically in BDC Meta Man soon.

posted @ 1:12 PM | Feedback (0)

Friday, February 16, 2007 #

Blog title changed

Renaud Comte made a good point to me during the Berlin Conference that perhaps many people don't actually know who's writing this blog that you are reading! So I've changed the title of it to 'Nick Swan's SharePoint Blog'. Hopefully that should give you some kind of an idea!

I've also been tempted to register a normal looking domain just for this blog as well for a little while but I get so many hits of Google searches now I'm not sure I'd want to risk losing them! Plus of course there is the risk of people subscibed to the old RSS feed not following me. Which brings up another important point, if you are subscribed to the old feed, make sure you start using the new feedburner one located here:

http://feeds.feedburner.com/Vb-techWeblog

That way if I do move it will all be seemless for you. There's around 500 people who still use the old RSS feed so make sure you use the new one! :-)

posted @ 5:35 AM | Feedback (1)

Building Virtual Machines for SharePoint 2007

At almost every presentation I do someone comes up and asks what setup I am using to demo SharePoint 2007 to get such good performance and the answer is always put the virtual machines on a usb hard drive.

Bob Fox has some great walk throughs on how to create your virtual machines for both Virtual PC and VMWare.

Post 1

Post 2

posted @ 5:12 AM | Feedback (0)

Thursday, February 15, 2007 #

Berlin SharePoint Conference day 2 + 3

Well day two and day three somehow got lost along the way so I've ended up writing this while waiting at Tegel airport for the flight home on day four.

Tuesday

Tuesday ended up being a really early start. On monday night I'd forgotten that I had signed up to be helping at the hands on labs from 8am to 10am. I managed to get there at 8:30 which wasn't too bad :-). All of the lab PCs were working now as well which was good news as from that point onwards the room was pretty full with a queue sometimes forming of people waiting to get on. The labs was a good place to meet up with the other MVPs as there was generally two or three were hanging around.

After my hands on labs duty Michael Greth interviewed me on BDC Meta Man for his SharePointPodCast.de. Thankfully the interview was in English! :-) I'll post a link to it when it's up on his website.

I attended Steve Smiths second session of the conference on Capacity Planning for SharePoint 2007. Really enjoyed this session as Steve gave away lots of real nuggets of things to think about when planning a deployment. The stress testing tool in VS 2005 looked really good as well although it seems a shame it's apparently only in the Software Testers Edition (didn't know that existed, or is it part of Team System?)

I managed to get some flowers ordered for valentines day which kept Sophie happy. I'd asked her to come to Berlin with me as being a teacher she had the week off for half term. She didn't want to though as she thought she'd be stuck at the hotel by herself all day. I only found out on the last day that a few other MVPs and attendees from the UK had bought their wives/girlfriends along. Next time I'll get Sophie to come as well.

The event in the evening for all the delegates was a suprise party so everyone piled into buses and headed off. People from the UK had a seperate area to congregate and drinks were kindly supplied by Artemis Corp. This was also the evening of the MVP dinner which we headed off to a little earlier and planned to join up with everyone else later. The place where we ended up eating though was around an hour away from the party so by midnight we realised it was too late to go across. Steve and I left around midnight as we were both pretty tired, but upon arriving on Wednesday we found out some people had managed to stay up drinking until 7am!

Here's Steve Smith, Stacy Draper, and Spencer Harbour. I'll let you guess which is which! :-)

Wednesday

I think three days is about the right length for a conference. Anything longer and I reckon people get a little fed up with it and start missing entire mornings/afternoons or may be even a day.

I managed to get my five minutes of presentation duties today. Mike Fitzmaurice asked me on Sunday if I'd like to come up and demo BDC Meta Man at the end of his session on Business Data Catalog. Mike was very kind in singing our apps praises before I'd even got up, and it was very nice that it got a round of applause when I showed how much xml was generated in the application definition file after just a few clicks. Afterwards quite a few people wanted to speak to me about the app which was great and I was at the Combined Knowledge stand most of the day so there was a trickle of people who were asking me questions. Here's a pic of me talking with the big video screen behind me

At 2pm it was time for the Combined Knowedge laptop draw! Tons of people turned up. A Sword colleague of mine, Deborah, had entered but actually left Berlin on Tuesday evening. You had to be here to win the laptop so I was going to pretend that it was her card that was pulled out. After the draw we actually realised her card was the next one on top so would her being chosen was very nearly the case.

After the final sessions of the day there was a little packing up to do, and then enjoying a few more beers with people at the hotel bar.

Overall I think the conference was great. The venue was brilliant (and massive), and there were so many staff organising and help the conference run smoothly. Thankfully everyone I met spoke English as well which was a great help. Thanks to everyone who came and said hello. It's nice meeting people who read your blog and encourage you to keep the writing going. Next conference I might be attending...TechEd perhaps in the US?

posted @ 7:46 PM | Feedback (0)

Monday, February 12, 2007 #

Berlin SharePoint Conference Day 1

Well the first day of the Berlin SharePoint Conference is over and I'm thankfully heading to bed quite soon. Last night I went out with a few other SharePoint MVP's and Microsoft Program Managers to try some traditional German food. Check out the size of the beer glasses!

 

It was really nice to catch up with Renaud and some of the other MVPs. I got up relatively early this morning, ate breakfast then headed over to the conference centre. I popped into the key note for a short while and it was packed! I didn't hang around in it for too long as it was stuff I'd seen many times before. Combined Knowledge are one of the premium sponsors of the conference and their stand is right outside the doors of one of the main halls. It's kind of become the unofficial meeting place for the UK delegates which is good as there's somewhere to go when you fancy a chat to someone.

Steve Smith and Brett Lonsdate both had talks on today. I popped into both to take pictures for them and record a litle bit of their session. They both had really good numbers in them. I might be making a brief appearance on stage on Wednesday with Mike Fitzmaurice to demo BDC Meta Man although that's not been confirmed yet.

There has been real issues with the Hands On Labs. Unfortunately only 8 pcs are working at the moment so my 2 hour stint as a helper didn't really lead to many questions! The entire room of machines should be back up by tomorrow though so future stints should proove to be a bit more interesting.

We've met up with some interesting people today. A few have recognised me from my blog, and a few stand there going 'Nick Swan, Nick Swan, where do I know that name from....?'
As soon as I mention BDC Meta Man everybody realises!

Tomorrow at the evening party, Rob Gray has organised a VIP UK Area for all the UK delegates. I've posted about it on SUGUK so pop over there to have a read of it.

Only real bad thing, people are allowed to smoke inside the conference centre! We're all going to be going home on Thursday smelling like ashtrays. :-(

posted @ 8:13 PM | Feedback (0)