Dedicated to development, configuration, and tips and tricks for both WSS 3.0 and MOSS

Workflow: SharePoint Designer or Visual Studio?

Posted by Aaron Varga on Friday, 9 Jan 2009 08:46
Lately I have been answering a number of questions related to workflows, specifically what you can and can't do with SharePoint Designer (SPD), and what advantages a custom Visual Studio workflow has over one created in SPD.  Basically, there are 3 ways to implement a workflow for SharePoint: use an out-of-the-box workflow, build a custom one using SharePoint Designer, or build a custom one from scratch using Visual Studio.  99.9% of the time, we eliminate the first option right away, as our clients rarely need something as simple as what the included workflows provide.  The following is a description of what's possible with the other 2 options, and how to make the right decision for which one to use.

 

SharePoint Designer

SharePoint Designer is obviously the preferred choice for creating workflows that need to do basic things, such as sequential document approvals, sending emails, creating tasks, etc.  The workflow designer wizard is user-friendly and easy to use, and attaching a workflow to a list or library is a cinch.  However, if you need to do something that's not given to you in the wizard, you don't really have much of an option other than to fire up Visual Studio and develop something custom.  Let's take a look at some of the things SPD can't do...

#1. [Lack of] Reusability
The most frequently mentioned limitation of SPD workflows is the inability to reuse them.  These workflows are bound to a list and site at design time through the workflow designer wizard, which does not offer the ability to publish to multiple locations.  This can potentially be overcome with manually copying the source files and updating the list and field ID's in the XML manually as described here, but this is extremely error-prone and not always effective.  I've seen cases where the source files were copied manually, the ID's were updated, the workflow republished, and the workflow still did not fire.  I didn't spend a significant amount of time troubleshooting it, just be aware that this is not a supported method of reusing workflows, and may not always work.

#2. Limited Conditions and Actions
With SPD you're basically limited to what is provided with the workflow designer wizard.  You're given a handful of conditions and a handful of actions, and that's what you have to work with if you're unwilling to write any code.  The included conditions and actions are simple and straight-forward and do not offer any customizations. Some of things that one might think SPD is capable of doing out-of-the-box, but can't:

  • Accessing Active Directory information directly, such as manager name or email
  • Kick off another workflow
  • Remove or grant permissions on the list item
  • Remove or grant permissions on a list, library, or site
  • Copy/move list items to a list in another site
  • Send emails with attachments
  • Jump to, or return to, another step in the workflow
  • Access information or content of the actual document in a document or form library -- SPD can only see the list columns.
  • Create or delete lists, libraries, sites
  • Wait for an item to change for a maximum amount of time

#3. No State-Machine Workflow Support
Workflows usually fall into one of two categories: sequential and state machine.  A sequential workflow is one that runs through all the steps and actions in sequence, one after another.  This may include parallel activities, where a bunch of people receive an email at once, for example, but the workflow as a whole runs from start to finish.  A state machine workflow represents a set of states, transitions, and actions. One state is denoted as the start state, and then, based on an event, a transition can be made to another state. The state machine would have a final state that determines the end of the workflow.  A state machine workflow is typically used when a particular step in a workflow needs to be repeated, such as during an approval process.  Take for instance the following scenario I encountered at a client:

A form to approve a product was created and submitted to a SharePoint form library.  This form when initially submitted needed to be routed to the requestor's manager.  The manager has the option to approve it and forward it on to the pricing manager, or reject it and send it back to the requestor, in which case that portion of the workflow would start over again, and would follow the same approval process.  If approved and sent to the pricing manager, this person would have the option to approve the form, send it back to the requestor, send it back to the manager, or send it back to both parties.  Yyyyeah...SPD can't do that.  There isn't a handy "Jump to Workflow Step" action.  The solution that was provided to the client was to handle a lot of the logic in the InfoPath form itself which used a decent amount of managed code in the form itself for some of this. All SPD was used for was to send emails.

In conclusion, if the workflow requires steps to be repeated, look elsewhere other than SPD.  If you're using an InfoPath form, you may be able to throw in enough logic there to do what you need, and if not a Visual Studio workflow may need to be explored.

#4. Limited User Data Collection
SPD provides a Collect Data From a User action that allows will create a task in the Task List and allow you to provided fields for the user to provide simple information.  For example, a single line of text, a checkbox, a drop-down list with pre-defined values, etc.  This creates an associated ASPX with custom SharePoint controls and logic, and cannot easily be modified.  In addition, you can't code the ASPX page to do anything custom in conjunction with the workflow, such as provide a drop-down list populated with SQL data, then use that elsewhere in the workflow.  Once again, you're limited to what you're given here.  A similar SPD action is Assign a To-Do Item, where you're able to specify some text which will create a task for a person and use the value you specify as the Task title. 

What's nice about a Visual Studio workflow is you are able to assign a custom task form to a task, which can be used to collect data.  This can be an InfoPath form or a custom ASPX form, and can contain custom code and logic, and the usual InfoPath and ASP.NET controls, respectively.  You can do whatever logic and data presentation you need to do, and are not restricted to what's provided out-of-the-box with SPD.

#5. Task/Action Dependencies
Another item not often thought of is the dependence of a task to the action that actually needs taken.  For example, a task can be created that says "Review this form and update some value", but how does the task know when it's completed?  If you bypass the task completely and go to the form and update the values and save it, the task will have no idea that the form has been updated.  Likewise, if you just complete the task without actually doing anything, it doesn't ensure that you did what you're supposed to do.

Since you control every step of the workflow in a custom VS workflow, you can enforce this dependency.  Do not provide complete buttons on your task forms, and leave it up to the running workflow to check the status of the submitted form and update the associated task accordingly.

These are just a few of the main points that continuously come up when designing workflows, and assessing whether or not SPD is the right tool.  Luckily, we haven't had many requests to provide the aforementioned functionality, so we've been able to make SPD jump through enough hoops to provide what they've needed.

When to Use SharePoint Designer
So, when is it a good idea to use SPD?  The answer is all of the time unless you absolutely can't.  If you can do it in SPD cleanly (key word being cleanly), then I recommend you do.  You won't find an easier way to create a simple task, send an email, or associate the workflow to a list, and you shouldn't recreate the wheel if the functionality is provided for you already.  If you need to do one of the items described above, or if you find yourself creating many individual workflows for the same "workflow", or if something you need to do can only be done using custom code, then consider writing a custom SPD activity or creating a workflow in Visual Studio.  Read on to find out if these other options are the right choices.

 

Custom SharePoint Designer Workflow Activities

As already mentioned, SPD gives you a handful of conditions and actions ("activities") out-of-the-box.  There are a ton of actions that I think should be included, but aren't.  Luckily, a framework is in place that allows developers to design their own SPD workflow activities, deploy them to a server, and have them be accessible to all workflows created in SPD.

Through a little bit of coding, configuration, and deployment, you are able to build your own activity that will appear in the SPD workflow designer wizard as an action.  This is plenty useful if you foresee a need to provide missing functionality to variety of workflows, such as an Active Directory lookup, or the ability to create sites or lists on the fly within a workflow.  Custom activities should only be considered when #1. the functionality isn't already included as an SPD action, and #2. the custom activity can be used for more than one workflow.  Custom activities are deployed globally, so it's not a good idea to create one specific to a single workflow, because there's nothing stopping other users of SPD from using it on one of their workflows, potentially screwing something up or doing something unintended.

Limitations of Custom SharePoint Designer Activities
While you can do almost anything with .NET code (and custom activities are written in .NET), you're still bound to the limitations imposed by the SPD workflow design process.  You still can't write an action to jump to a particular step in the workflow, you still can't have the workflow run as another user (you can run your custom activity as another user, however), you still can't move SPD-authored workflows around easily, etc.  You can do whatever you want for that particular action in that particular step of the workflow, but you're still constrained to using the SPD workflow designer.

When to Use Custom SharePoint Designer Activities
Custom activities are a nice middle-ground between what you're given with SPD by default, and building a workflow from scratch using Visual Studio, but keep in mind they serve a very specific purpose: to provide common functionality to all workflows.  Since they're available in the wizard, they are able to be used in any workflow.  If you haven't picked up the point yet, do not create a custom action that shouldn't be used by more than one workflow!

Useful SharePoint Designer Custom Workflow Activities
Luckily, other developers have seen the light when it comes to custom activities, and have built a few useful ones to address some of the missing functionality described above.  The following activities can be downloaded here:

  • Send Email with HTTP Attachment
  • Send Email with List Item Attachments
  • Start Another Workflow
  • Grant Permission on Item
  • Delete List Item Permission Assignment
  • Reset List Permissions Inheritance
  • Is User a Member of a SharePoint Group
  • Is Role Assigned to User
  • Lookup User Info
  • Copy List Item Extended Activity
  • Send Email Extended

 

Visual Studio Workflows

All workflows used in SharePoint rely on Windows Workflow Foundation (WWF), which is a piece of .NET goodness introduced in version 3.0.  Whether it's an out-of-the-box workflow, or SPD-authored workflow, they're all powered using this technology.  The difference with those 2 options versus creating one yourself in Visual Studio is most of the leg work and overhead is already done for you.  With Visual Studio it's up to you, the developer, to code every single thing that needs to happen during the workflow.  It's important to note that by creating a custom workflow in Visual Studio, it's not going outside the bounds of an appropriate workflow-creation tool -- Visual Studio is just another tool to use to create SharePoint workflows, and a very powerful one at that.

What's wonderful about a workflow created from scratch is you're given all the power to decide what you want the workflow to do.  You're not bound to certain conditions or certain activities like you are with SPD.  In addition, some workflows (like a state-machine workflow) aren't even possible in SPD, so Visual Studio must be used.

Visual Studio workflows also enable you to use custom forms at certain points in the workflow.  A custom InfoPath form or ASPX page can be written to display or collect any information that you want, and have that integrated into the workflow.  For example, if you need to collect information or provide user-configurable options when assigning a workflow to a list, you can develop an association form that collects this data. If you need to collect information when the workflow is kicked off for a particular item, you can implement an initialization form.  You can even collect information during the workflow using custom task forms.  For workflows that need a significant amount of user-provided data during the workflow in order to make decisions inside that workflow, Visual Studio will probably need to be leveraged to provide a custom form for that data collection.

Finally, Visual Workflows are reusable and moveable.  They're implemented as SharePoint Features, and only need installed and activated on whatever SharePoint environment you're using.  You assign the workflow to a list at runtime, not design time like you do with SPD.  You can use the same workflow on 100 different lists if you need to.  In SPD, you would have to recreate that same workflow 100 times, or make 100 copies of the workflow in order to achieve this.

Drawbacks of Visual Studio Workflows
Obviously the drawback to building a custom workflow in Visual Studio is the time it takes to do so.  With the out-of-the-box and SPD-authored workflows, so much of the initial overhead is done for you, and it's easy to take that for granted.  It's up to you to decide exactly what is supposed to happen, how to get the data from the list item as needed, and make the decisions in the workflow.  Visual Studio uses a number of activities that help facilitate this, but it is a time-consuming and cumbersome process.

Another drawback is implied from the first: only developers have the ability to create these workflows.  An advantage of an SPD workflow is that business users are [usually] smart enough to create them, and don't need to contact IT or a developer to do it for them (yes, I know what I just said, but that's the intended use of SPD...)

When to Use Visual Studio Workflows
The default answer for this is....use a Visual Studio workflow when you can't do something with an out-of-the-box workflow or with SPD.  If you need to implement a state-machine workflow, or you need to collect a lot of complex information from a user during the workflow, or you need to reuse a workflow over and over again, etc., then you should build it in Visual Studio.

This next answer should have as much weight as the previous...build a Visual Studio workflow if it will result in a better-architected, cleaner solution.  It may very well be possible to accomplish something using a combination of SPD workflows and a handful of custom actions, but rarely is that good design.  By having multiple moving parts, you're introducing multiple points of failure that each have to be maintained.  It is better to force a good solution than to force a particular tool on a client.

 

So, How Do I Choose?

Great question!  The answer is easy -- do the simplest thing possible that will result in a clean solution.  If you can implement the requirements with an out-of-the-box workflow, use that.  If you can implement the workflow in SPD using the included conditions and activities, use that.  If you can use SPD for all but one tiny thing that could be addressed by a reusable activity, build one and use SPD.  And if you can't provide the requirements in a clean, maintainable solution using SPD, then build it in Visual Studio.

Posted by Aaron Varga | 0 Comments | Trackback Url | Bookmark with:        
Categories: Workflow

Links to this post

Trackback from wss.made4the.net: by Jeremy Thake on 20 Feb 2009 02:43

Trackback from Casino 1242955280 on 21 May 2009 08:35

Trackback from sdiywhir on 22 May 2009 08:15

Trackback from Casino 1243045918 on 22 May 2009 10:14

Trackback from Casino 1243052402 on 22 May 2009 11:52

Trackback from Casino 1243056365 on 23 May 2009 12:47

Trackback from Casino 1243115379 on 24 May 2009 01:12

Trackback from Casino 1243365450 on 29 May 2009 10:49

Trackback from txjrzlwq on 18 Jul 2009 10:18

Trackback from qkktivql on 20 Jul 2009 12:34

Trackback from vlydbsur on 23 Jul 2009 08:52

Trackback from fwiskcjg on 23 Jul 2009 09:15

Trackback from jedoifyi on 23 Jul 2009 10:23

Trackback from nnpjqhzb on 23 Jul 2009 10:58

Trackback from urpxurhq on 23 Jul 2009 11:54

Trackback from ijsewbcq on 24 Jul 2009 01:11

Trackback from mexxkijt on 31 Jul 2009 07:15

Trackback from qigyihzt on 06 Aug 2009 01:37

Trackback from Casino 1249772306 on 09 Aug 2009 12:05

Trackback from Casino 1249883930 on 12 Aug 2009 11:16

Trackback from Casino 1250191482 on 14 Aug 2009 06:00

Trackback from Casino 1250533814 on 17 Aug 2009 02:26

Trackback from Casino 1250538984 on 17 Aug 2009 02:53

Trackback from Casino 1250624386 on 18 Aug 2009 02:25

Trackback from Casino 1250625839 on 18 Aug 2009 02:47

Trackback from Casino 1250627697 on 18 Aug 2009 04:38

Trackback from Casino 1250633977 on 18 Aug 2009 05:24

Trackback from Casino 1250699013 on 19 Aug 2009 12:21

Trackback from Casino 1250722054 on 19 Aug 2009 09:04

Trackback from jwgvubpq on 29 Aug 2009 04:07

Trackback from jwgvubpq on 29 Aug 2009 04:07

Trackback from chagfpfa on 12 Feb 2010 10:15

Trackback from download skins for windows media player on 03 Mar 2010 04:33

Trackback from cialis discount on 15 Mar 2010 08:08

Trackback from health benefits of low dose cymbalta on 16 Mar 2010 05:34

Trackback from buying cialis online uk on 16 Mar 2010 05:41

Trackback from cheap cialis on 16 Mar 2010 06:25

Trackback from viagra bestellen online on 16 Mar 2010 06:47

Trackback from cheapest generic cialis in Surry VA 23883 Virginia on 16 Mar 2010 06:52

Trackback from viagra billig bestellen on 16 Mar 2010 07:07

Trackback from cialis online pharmacy 100/100mg pills $1.35 each on 16 Mar 2010 07:33

Trackback from best time to take lexapro 50mg on 16 Mar 2010 07:47

Trackback from swedish to english translation on 19 Mar 2010 07:26

Trackback from plzqfooh on 24 Mar 2010 06:56

Trackback from oajvoyqs on 24 Mar 2010 09:14

Trackback from apcidswg on 24 Mar 2010 09:31

Trackback from qqxseqzr on 26 Mar 2010 09:42

Trackback from kuzyapyp on 27 Mar 2010 12:17

Trackback from wulhzgam on 27 Mar 2010 12:54

Trackback from asnzcawn on 27 Mar 2010 03:07

Trackback from phawtaao on 27 Mar 2010 03:58

Trackback from krlxhmmd on 27 Mar 2010 07:42

Trackback from Casino 1269728909 on 27 Mar 2010 06:55

Trackback from Casino 1269728908 on 27 Mar 2010 06:55

Trackback from Casino 1269729422 on 27 Mar 2010 06:55

Trackback from likxjneq on 27 Mar 2010 08:53

Trackback from Casino 1269771703 on 28 Mar 2010 11:30

Trackback from Casino 1269771815 on 28 Mar 2010 11:30

Trackback from Casino 1269772318 on 28 Mar 2010 11:52

Trackback from wuohmzno on 31 Mar 2010 11:12

Trackback from Casino 1270230446 on 02 Apr 2010 03:51

Trackback from Casino 1270231741 on 02 Apr 2010 03:51

Trackback from Casino 1270232424 on 02 Apr 2010 03:51

Trackback from Casino 1270494559 on 05 Apr 2010 06:20

Trackback from Casino 1270493914 on 05 Apr 2010 08:57

Trackback from aofgypti on 06 Apr 2010 11:20

Trackback from cheap cialis on 16 Apr 2010 03:20

Trackback from faxless easy online payday loans on 16 Apr 2010 03:20

Trackback from buy cipro 250mg in Valley springs SD 57068 South Dakota on 05 May 2010 08:04

Trackback from Casino 1273771865 on 13 May 2010 04:51

Trackback from Casino 1273771396 on 13 May 2010 06:34

Trackback from Casino 1273771956 on 13 May 2010 06:34

Trackback from Casino 1273772417 on 13 May 2010 06:34

Trackback from Casino 1273772500 on 13 May 2010 11:24

Trackback from Casino 1273971839 on 16 May 2010 01:25

Trackback from Casino 1274018354 on 16 May 2010 10:30

Trackback from Casino 1274180235 on 18 May 2010 07:03

Trackback from Casino 1274178521 on 18 May 2010 07:35

Trackback from Casino 1274179362 on 18 May 2010 08:31

Trackback from Casino 1274311448 on 19 May 2010 10:05

Trackback from Casino 1274433794 on 21 May 2010 06:43

Trackback from Casino 1274566454 on 23 May 2010 04:49

Trackback from Casino 1276648322 on 15 Jun 2010 11:23

Trackback from Casino 1276643979 on 15 Jun 2010 11:23

Trackback from Casino 1276644814 on 15 Jun 2010 11:23

Trackback from Casino 1276715057 on 16 Jun 2010 06:08

Trackback from Casino 1276717002 on 17 Jun 2010 12:48

Trackback from Casino 1276953490 on 19 Jun 2010 11:22

Trackback from Casino 1277139884 on 21 Jun 2010 01:07

Trackback from Casino 1277214763 on 22 Jun 2010 10:57

Trackback from Casino 1277306709 on 23 Jun 2010 01:08

Trackback from Casino 1277733784 on 28 Jun 2010 01:43

Trackback from Casino 1280331167 on 28 Jul 2010 02:00

Trackback from Casino 1280345989 on 28 Jul 2010 06:13

Trackback from Casino 1284491528 on 14 Sep 2010 05:15

Trackback from Casino 1287050304 on 14 Oct 2010 07:36

Trackback from Casino 1290150433 on 19 Nov 2010 04:17

Trackback from Casino 1290852380 on 27 Nov 2010 07:30

Trackback from Casino 1292243887 on 13 Dec 2010 10:10

Trackback from Casino 1297161962 on 08 Feb 2011 08:11

Trackback from Casino 1299680089 on 09 Mar 2011 01:23

Trackback from commander viagra on 29 Jan 2012 04:24

Trackback from nymphomax on 04 Feb 2012 04:54

Trackback from mujeres para hacer el amor on 18 Feb 2012 12:49

Trackback from free penis pills on 19 Feb 2012 04:55

Trackback from posters printing on 21 Feb 2012 07:44

Trackback from First Date Guides on 21 Feb 2012 08:24

Trackback from estrogen on 23 Feb 2012 09:12

Trackback from The most successful Is WHAT Website on 26 Feb 2012 07:42

Trackback from receive outlook on 02 Mar 2012 03:30

Trackback from posters printing on 02 Mar 2012 08:38

Trackback from autism treatments on 03 Mar 2012 09:56

Trackback from The friendliest WORKFLOW Website on 04 Mar 2012 05:28

Trackback from auto insurance on 04 Mar 2012 12:41

Trackback from my articles on 06 Mar 2012 06:07

Trackback from bingo cams on 07 Mar 2012 07:40

Trackback from printing posters on 07 Mar 2012 09:20

Trackback from dj table on 08 Mar 2012 12:07

Trackback from lion king broadway tickets on 09 Mar 2012 07:40

Trackback from Zestril side effects, Side Effects of Zestril, Zestril on 09 Mar 2012 10:56

Trackback from legal herb shop on 10 Mar 2012 05:46

Trackback from synchronize on 10 Mar 2012 08:01

Trackback from political postcards printing on 10 Mar 2012 09:28

Trackback from mortgage loans calculator on 17 Mar 2012 06:16

Trackback from Backlink on 19 Mar 2012 03:39

Trackback from revista online on 21 Mar 2012 06:06

Trackback from lion king broadway tickets on 22 Mar 2012 07:44

Trackback from Medigap Insurance on 27 Mar 2012 09:44

Trackback from Online coupon clipping service on 30 Mar 2012 02:29

Trackback from powerful print audit tool on 31 Mar 2012 10:19

Trackback from get car insurance quote online on 06 Apr 2012 05:12

Trackback from popcorn calories on 11 Apr 2012 08:24

Trackback from cheapest car insurance guaranteed on 13 Apr 2012 11:27

Trackback from Online coupon clipping service on 13 Apr 2012 11:29

Trackback from car insurance quotes on 15 Apr 2012 09:18

Trackback from car insurance quotes on 15 Apr 2012 10:47

Trackback from Peliculas Online on 17 Apr 2012 07:13

Trackback from website promotion on 20 Apr 2012 06:43

Trackback from programa de gestion prestashop on 23 Apr 2012 05:15

Trackback from gold forum on 23 Apr 2012 05:40

Trackback from juegos gratis on 24 Apr 2012 03:00

Trackback from canciones online on 24 Apr 2012 10:50

Trackback from learn spanish verbs first on 27 Apr 2012 10:35

Trackback from audio books to learn spanish for children on 27 Apr 2012 03:10

Trackback from canciones online on 30 Apr 2012 01:05

Trackback from jugar gratis on 04 May 2012 04:21

Trackback from direktimport auto on 04 May 2012 02:37

Trackback from hgh benefits on 04 May 2012 11:46

Trackback from short term loan on 06 May 2012 05:15

Trackback from payday advances on 08 May 2012 02:39

Trackback from short term loan on 08 May 2012 01:45

Trackback from buy hgh on 11 May 2012 10:49

Trackback from Custom Facebook Fan Page on 11 May 2012 08:47

Trackback from חשבונית לעוסק פטור on 12 May 2012 08:22

Trackback from read more on 13 May 2012 02:48

Trackback from vitamin a cream for face on 15 May 2012 11:08

Trackback from cancionesonline.net on 16 May 2012 02:46

Trackback from bridging finance on 16 May 2012 08:43

Comments



Name

Url

Email

Comments

CAPTCHA Image Validation