Deploying a .NET, Visual Studio Workflow into a SharePoint List in 10 Easy Steps (Part 2 of 2): Deploying the Workflow 

Tags: SharePoint Development

In the first post of this series, we walked through the basic steps to creating a workflow in visual studio. In this second part, we'll cover the remaining 5 steps necessary to deploy that workflow onto a SharePoint list, and thereafter invoke that workflow which will create a task automatically and demonstrate that the workflow is indeed functioning.

 

Part 2: Deploying a .NET workflow onto a SharePoint List

 

  1. All visual studio workflows and their assemblies must be strongly named and deployed into the global assembly cache (GAC).

    To do this, right click on the project and click "Properties". Under the "Signing" tab, check to sign the assembly and choose "New" in the drop down:


    (Figure 1 – Signing an assembly with a new key pair file and public key token)

    Type a name of "TestWorkflowKeyPair", and uncheck to password protect the assembly.

    Lastly, build the project and drag and drop the resulting DLL file into the GAC, c:\windows\assembly

  2. All .NET workflows are deployed into SharePoint via a feature, and we'll need to create and deploy these feature files before we'll be able to instantiate our workflow on our SharePoint List. If you remember from my last post, the best way to do this deployment across your farm would be through a solution deployment. In order to keep this post concise, and since I'm deploying to a standalone development environment, I'm going to do a manual deployment of my feature. However, if you're curious about solution deployments, view this post that contains some links to some good content around that subject.

    Now, to our manual deployment - you'll notice that the workflow template generated the "Deployment Files" folder with the feature.xml and workflow.xml files already available for us to edit.


    Edit the feature.xml files as follows (you'll need to generate your own unique GUID - title, description, and version can be to your heart's desire):

    (Figure 2 – feature.xml feature file details)

    Edit the workflow.xml file as follows (replace the highlighted section with your public key token, learn how to retrieve here):

    (Figure 3 – workflow.xml feature file details)

    NOTE: the "CodeBesideAssembly" property CANNOT be wrapped or the workflow will fail! Don't wrap within the double quotes.

    Save both those files and create a new folder under the 12 hive, TEMPLATE\FEATURES directory named "NewTaskWorkflow":

    (Figure 4 – Feature folder example)

    RESTART ISS! All the XML in the 12 hive is cached, so a restart is needed. Start -> run -> iisreset.

  3. Install and activate the NewTaskWorkflow feature.

    Open STSADM.exe under the 12 hive, BIN folder, and run the following command: "stsadm –o installfeature –name NewTaskWorkflow":

    (Figure 5 – STSADM operation completed)

    Activate the newly installed feature by navigating to the "Site Collection Features" page, under "Site Action" -> "Site Settings". Scroll down until you see "New Task Workflow", and click "Activate":

    (Figure 6 – activate the workflow feature at this Site Collection's scope)

  4. Enable the workflow on a SharePoint list and list item.

    I'm going to create a new Issue Tracking list called "Development Issues", wherein I'm going to enable my custom workflow. Once you have the list created, click "Settings" -> "List Settings". Then, click the "Workflow Settings" link:

    (Figure 7 – workflow setting location)

    Because the workflow feature was activated at this site collection, you'll notice our workflow appears in the list of available workflows. Go ahead and give it a name:

    (Figure 8 – workflow in list, and a name of "New Task Workflow")

    The next setting is relates to the task list that we'll be adding items into. Since I don't have any existing Tasks lists, I'm leaving the default to create a new one. Workflow history is very similar, you can log information, at your discretion, to this history log. In the start options section, I'm going to change the setting so my workflow is automatically invoked upon a new list item being created.


    (Figure 9 – additional workflow settings)

    Click Ok. You'll notice if you go to view all site content, the Tasks list was automatically provisioned for us.

  5. Finally – let's navigate to our Development Issues list, and create a new issue. After you create the issue, navigate to your tasks list and you'll see a new task with "ACTION ALERT! New issue created!" as its title!


Congratulations! You're now a workflow expert! ;)

Click here to download my project if you couldn't get yours to work. Also, feel free to leave a comment if you have any questions.

 

Phil

 
Posted by Phillip S. Wicklund on 12-Feb-08
21  Comments  |  Trackback Url  | 0  Link to this post | Bookmark this post with:        
 
Failed to render control: Value does not fall within the expected range.

Comments


Just what the doctor orderedcommented onWednesday, 2-Apr-2008
Great distillation of the topic. Have you been able to build a State Machine Workflow and deploy it? I can get one going in a console app no problem, but don't know where to start in hooking one into MOSS 2007. Any suggestions/advice appreciated. Bob


(RE) Just what the doctor orderedcommented onWednesday, 2-Apr-2008
I actually have never tried to get a state machine to deploy onto a SharePoint list - in fact I've heard that it is not possible. However, that's just hear say ;). It makes some sense though, because you can't build a state machine in SharePoint designer. I'm not sure if that is for technical reasons, of if the dev team just didn't have the time to get it in. Either way, a different option would be to deploy a static link via a feature into the list item menu of a given list where you want workflows to be initiated off of. You could then use that link/menu item to navigate users to your state machine. Give me a hollar if you think of a better way! Phil


Priyank Tiwaricommented onFriday, 4-Apr-2008
getting problem to load infopath after deployment of workflow in sharepoint


Statemachine -- WSScommented onTuesday, 22-Apr-2008
Statemachine workflows work in WSS3.0 follows the same lead, create your XOML file, with the appropriate classes and association/initiation forms. Then make sure to install the DLL into the GAC and then copy over the files and do the stsadm commands. I tie the statemachines, in general practice, to list so it monitors onWorkflowItemChange to kick off the events in the states.


State-machine workflowscommented onTuesday, 22-Apr-2008
I was able to mimic state-machine behavior using SharePoint Designer, and also blogged about it here: http://coredotnet.blogspot.com/2008/03/creating-state-machine-workflows-using.html While I can develop a state-machine workflow in VS2005 and associate it with a list, I dont get any result when I manually start a workflow instance. Any comments or suggestions?


how to do State Machine in SharePointcommented onFriday, 30-May-2008
I think you can't do SMs if you use the SharePoint Designer tool, but it seems like you can do it using Visual Studio; here's a video showing how: http://msdn.microsoft.com/en-us/office/cc514057.aspx


commented onMonday, 27-Oct-2008


Samer Najiacommented onFriday, 14-Nov-2008
Here's what I'm after: an uploaded document fires off a workflow where the approver can be one of many. If one person in the list approves, the document moves forward. If not, it gets rejected and goes back one level down. If it gets approved it fires off a second workflow. If it gets rejected, it fires off or could fire yet another workflow and so on. The idea is for us to be able to combine parallel and serial workflows and keep the document in the 'loop' until it passes muster or the workflow is manually terminated. Is this at all possible? Any thoughts? Thanks, Samer


Nikecommented onSaturday, 15-Nov-2008
Great info. Thanks!


Saracommented onSaturday, 15-Nov-2008
Hi, thanks for the great information.


Lindacommented onSaturday, 15-Nov-2008
great nice imformation!


Madlencommented onSaturday, 15-Nov-2008
Very nice site!


Jekicommented onSunday, 16-Nov-2008
A great resource - many thanks!


Jinacommented onSunday, 16-Nov-2008
A great resource - many thanks!


Jinacommented onSunday, 16-Nov-2008
A great resource - many thanks!


Pitcommented onSunday, 16-Nov-2008
Very nice site!


Jeksoncommented onSunday, 16-Nov-2008
I have bookmarked this page too. Great resource.


Juliycommented onSunday, 16-Nov-2008
A great resource - many thanks!


Patrikcommented onSunday, 16-Nov-2008
A great resource - many thanks!


Elencommented onMonday, 17-Nov-2008
Very nice site!


Garycommented onMonday, 17-Nov-2008
A great resource - many thanks!

Name:
URL:
Email:
Comments: