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

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 on Monday, March 05, 2007 8:51 PM

Get email alerts when this blog is updated!

Feedback

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 3/8/2007 2:21 PM John

When I associate my workflow with a custom list, I select it from the dropdown and then give it a name. I then get this on the resulting page: "The form has been closed"

Any ideas where I went wrong?

# Installing on Windows Server 2003 when developing on Windows XP 3/13/2007 2:07 PM Charles Crichton

If you are developing on a Windows XP machine, rather than on a Windows 2003 machine. Perhaps having followed the instructions at [1] then the above instructions will not quite work. However some simple modifications can get you up and running.

[1] http://zgud.spaces.live.com/blog/cns!76596824C411964C!142.entry


GacUtil.exe

First of all you won’t have gacutil.exe on your Windows 2003 machine. So create an extra directory called ‘util’ in your project and copy gacutil.exe and gacutil.exe.config into it. (See PostBuildActions.bat for location of these files on your development machine.)
Add the following line to PostBuildActions.bat somewhere before the line with “ECHO Gacutil.exe could not be found!” in it.

IF EXIST "%~dp0\..\util\gacutil.exe" (SET GACUTIL="%~dp0\..\util\gacutil.exe" & GOTO DEPLOY)


Extra batch file

Then add the extra batch file, DeployToNonBuildMachine.bat, to the DeploymentDirectory:

@ECHO OFF
::Use this to deploy the script on a non-build machine
::You will need to edit the project name.

set ProjectName=CharliesWorkflow

set DeploymentDir=%~dp0
echo "DeploymentDir = %DeploymentDir%"
set ProjectDir=%DeploymentDir%\..
set TargetDir=%ProjectDir%\bin\Debug
set Targetname=%ProjectName%

call "%DeploymentDir%\PostBuildActions.bat" DEBUG "%ProjectDir%" "%ProjectName%" "%TargetDir%" "%TargetName%" DEPLOY


Build, copy and deploy!

Build the solution then copy the directory containing the project to your Windows 2003 machine and call the DeployToNonBuildMachine.bat

Hope this helps,

Charles Crichton
CancerGrid Team
Oxford University Computing Laboratory

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 3/13/2007 5:19 PM Isabelle

I don't see the forms in the ..\12\TEMPLATE\FEATURES\[myworflowname]\ I only see the workflow.xml and feature.xml. What did I missed.

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 3/14/2007 7:05 AM Fred

Hy.
I have read your post and done exactly the same.
Now I want to test it.
How can I test? I have to post a document on my Sharepoint website and start the worklow? Or is it done automatically?

When I go to the "Site collection Features" and in "Worklow galerie", I see the created worklow (it is activated).

But when i want to start the workflow on a document, I can choose It.I only have the default workflows : "Approval" and "Collect feedback".

Can you help me please.

Thanks

Fred

(scuse my english but I'm french ;) )

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 3/14/2007 10:26 AM Fred

I hace a pb when I start workflof.
In fact, after complete the form, I have the message "Failed on start" in the column of my document.

Can you resolve my problem?

Thanks all

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 3/15/2007 12:45 PM Wouter

Don't forget to activate the feature with

stsadm -o activatefeature -name <feature FOLDER name> -url <your website URL>

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 3/22/2007 9:02 AM Nick Sevens

Thanks Wouter,

That's exactly what the problem was with me :D

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 3/22/2007 3:50 PM Magnus

Hi,

First. Great articles Nick!

I am still getting to know how to develop workflows and find this stuff cool.

However, after having developed and deployed this demo I get "Failed on Start" when I start the workflow on a document. I know this was originally created for Contact List , but it should work on document libraries as well right?

Any clues?

thx

Magnus

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 3/27/2007 8:28 AM Jonathan Hobbs

Hi Nick,

I am having problems with the TaskListContentTypeId.

I have got a workflow working fine in SharePoint, I can start a workflow from code and it assigns tasks into the task list ok.

I've now created a new SharePoint web app with new site collection on the same server. I have set up my workflow exactly as for the first app, but this time when I try to start the workflow from code it is not starting. Debugging the code, I get the exception 'The requested workflow task content type was not found on the SPWeb'. Checking the TaskListContentTypeId in my workflow.xml I have 0x01080100C9C9515DE4E24001905074F980F93160, exactly the same as my working example and the same as your example. If I then examine the available content types for my task list (by selecting 'Allow management of content types' in Advanced settings for the task list), I only have the Task content type available. However, in my working app, the task list has an extra content type called 'Office SharePoint Server Workflow Task', which when I click on its parent content type I see the id (0x01080100...) as above in the url.
Clearly my new site is missing this content type. But I cannot add it to the site by selecting it from Site Content Types because it is a hidden content type and is therefore not listed. I can't fathom why it's not appearing on my new site, just as the other one.
Is there something obvious that I need to enable for my new site? I have compared the two and can't see anything different between them.

Any help much appreciated.

Jonathan.

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 3/27/2007 3:42 PM Isabelle

Hi,

Please help, I'm stuck because I get the following error "the form has been closed" when adding the workflow to my form library. When I tried another time I got the Error page of InfoPath Forms services with the following error "The specified form cannot be found.". My forms are under the folder 12\TEMPLATE\FEATRES\[FOLDER NAME]. I don't understand.

Please help me! I need this to work.

Thanks
Isabelle

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 3/28/2007 1:39 PM Jonathan Hobbs

Hi Nick,

Following my post about the TaskListContentTypeId, after 2 days of pulling my hair out I have finally found the answer, and as is often the case, it was staring me in the face.
The reason my workflow couldn't find the Office SharePoint Server Workflow Task content type was that I hadn't installed the relevant SharePoint feature! Fishing around in the 12/TEMPLATE/FEATURES folder, I located the OffWFCommon feature which contains an xml file CTypes.xml which contains a reference to the TaskListContentTypeId (0x01080100C9C9515DE4E24001905074F980F93160) I was looking for. Then I installed it on the web app using the stsadm installfeature command. And guess what, my workflow now works!
I still don't understand why it worked on my original SharePoint site, as I don't recall having to install it in the first place.

Hope this saves someone else from early baldness.

Cheers

Jonathan.

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 4/5/2007 11:30 AM Ruben Biesemans

Hi!

I found this post (and the one explaining how to create the workflow and the infopath forms) very interesting.

However I also have the problem that when I associate the workflow with a library I get the message "The form has closed"...

Is there anyone who has an explanation for this?

Before I got a message about not finding the correct infopath form, but after re-running the bat file to (un)install and (de)activate the feature, i go straight to the "The form has closed" message.

Does it matter that I am not developping this on the same machine as where I deploy it on?

After compiling on my development pc, I copy everything to my sharepoint server machine and there I run the install.bat

Help is appreciated. :-)

Ruben

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 4/12/2007 6:25 PM Andy

My question is not refering directly to this article but this cool aricle inspired me to experimenting with workflows :)
So...
In a ReviewRouting_Init_1045.xsn file (I've opend it in a Design view) from ..\Features\ReviewWorkwlows\Forms\ and I've changed one text in one place. I've saved this .xsn file and restarted iis. When I try to run this review workflow on my sharepoint site on the init form I always see the old text :(. What should I do to see changes I've made to ReviewRouting_Init_1045.xsn ?
I've spent 3 hours to resolve this problem but without any result:(
It is very urgent for me because my client is waiting for this changes so I'll be very thankfull if somone help me as quick as possible.

Thank You in advance.

Andy

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 4/15/2007 1:49 PM Vladimir Davidov

Hello!
I have the following problem –
after successfully deploying workflow with the script, suggested by Charles Crichton (whom I thank A LOT for a great advice), I tried to configure a workflow for a document library by choosing “Seettings” --> “Document Library Settings” and then in section “Permissions and Management” item “Workflow settings”.
On workflow configuration screen in section “Workflow” I chose custom workflow, which has been deployed, entered a name for it, in section “Start options” checked “Start this workflow when a new item is created ” and pressed “Next”.
This was the place, where problems starter – I saw a message “The form has been closed” without any details, to try to identify what was the problem I turned on diagnostics logging on the site and that’s what I’ve got:
“MetaInformationByUrl:CrossSite check failed for site URL=http://spssrv01:20327 and file URL=: urn:schemas-microsoft-com:office:infopath:InitForm:-myXSD-2007-04-10T17-25-06”
Now I’m positive about form URN, because I checked many times whether it is what is in form properties. And it was not published to any other site on this server as well. This is the only server in the farm and Web enabled forms as well as workflows are enabled on it in this particular site, where I’m testing the solution. If I publish an InfoPath form on the server as library content type (another form in different library) I can configure any standard workflow to process it without any problems. Oh yes – I could not find any details on “MetaInformationByUrl:CrossSite” message on the net :(.

Could someone please explain what is the problem and give an advice on how to tackle it?

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 4/18/2007 5:58 PM kesa

Hi,
My workflow is reated successfully. How can i use that in the site?
I tried by attaching it to content type and then i attached the form to the content type. But the initiation form we created does not appear at all. What is the mistake i am making here.
thanks,

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 4/18/2007 6:00 PM kesa

Hi,
My workflow is created successfully. I am not sure how to make use of it.
Tried create content type and attach the work flow to that. Then created form library and attached the content type to that form library. When i tried to create a new form based on that content type it is not able to recognize the template on which the form has to be created. What is the mistake i am doing here

# re: Deploying our SharePoint 2007 Workflow with Visual Studio 2005 + InfoPath 2007 (RTM VERSION!) 4/20/2007 11:20 AM Jean-Pierre Fouche

Any advice on a strategy for debugging sharepoint workflows?

Title  
Name  
Url
Comments - All Comments are moderated and will not be displayed until approved by this blog's author    
Enter the code you see: