Workflow: A deep dive into developing workflows using Visual Studio and InfoPath Chris O’Brien – SharePoint MVP  http://ww...
<ul><li>Workflow intro </li></ul><ul><li>Key decisions </li></ul><ul><ul><li>Can I use an SPD workflow instead of Visual S...
<ul><li>SharePoint workflows are  always  associated with content e.g: </li></ul><ul><ul><li>Document </li></ul></ul><ul><...
Introduction <ul><li>Different workflow types: </li></ul><ul><ul><li>VS workflows require coding ability (and ideally Info...
<ul><li>Advantages of SPD workflows: </li></ul><ul><ul><li>Built using wizard, not code </li></ul></ul><ul><ul><li>Powerfu...
<ul><li>Sequential workflow: </li></ul><ul><ul><li>‘ Traditional’ design </li></ul></ul><ul><ul><li>Generally flow downwar...
<ul><li>State machine workflow: </li></ul><ul><ul><li>Series of ‘states’ e.g: </li></ul></ul><ul><ul><ul><li>‘ Awaiting in...
<ul><li>InfoPath or custom .aspx forms? </li></ul><ul><li>Factors: </li></ul><ul><ul><li>InfoPath forms quicker to develop...
<ul><li>Item for workflow: expenses form (InfoPath) </li></ul><ul><li>Process: </li></ul><ul><ul><li>User submits expense ...
Acme expense workflow – first steps demo
<ul><li>We just hit them: </li></ul><ul><ul><li>#1: Using activities  – two ways to set properties: </li></ul></ul><ul><ul...
<ul><li>How do I get at the information which was entered into the form? </li></ul><ul><li>Can write code to parse XML e.g...
<ul><li>How do I work with SharePoint tasks? </li></ul><ul><ul><li>CreateTask </li></ul></ul><ul><ul><ul><li>Set propertie...
<ul><li>Always always design in Visio first! </li></ul><ul><li>Error/bug? Check the SharePoint logs first </li></ul><ul><l...
<ul><li>SharePoint has different levels of workflow </li></ul><ul><li>Key decisions summary: </li></ul><ul><ul><li>OOTB/SP...
Downloadable resources:  http://www.sharepointnutsandbolts.com/2008/01/resources-from-my-workflow-deep-dive.html Blog:  ww...
Upcoming SlideShare
Loading in …5
×

SharePoint workflow deep-dive

3,438 views

Published on

My presentation to the UK SharePoint User Group in January 2008 on SharePoint workflow. During the presentation I developed a state-machine workflow over several demonstrations. A downloadable \'resources pack\' of workflow tips and tricks accompanied this presentation, available at http://www.sharepointnutsandbolts.com/2008/01/resources-from-my-workflow-deep-dive.html.

  • Be the first to comment

SharePoint workflow deep-dive

  1. 1. Workflow: A deep dive into developing workflows using Visual Studio and InfoPath Chris O’Brien – SharePoint MVP http://www.sharepointnutsandbolts.com
  2. 2. <ul><li>Workflow intro </li></ul><ul><li>Key decisions </li></ul><ul><ul><li>Can I use an SPD workflow instead of Visual Studio? </li></ul></ul><ul><ul><li>Sequential vs. state machine workflows </li></ul></ul><ul><ul><li>ASPX vs. InfoPath forms </li></ul></ul><ul><li>Visual Studio workflows in detail </li></ul><ul><ul><li>The 4 complexities of workflow </li></ul></ul><ul><li>Chris’s workflow bonanza pack! </li></ul><ul><ul><li>7 key resources, 5 ‘how-to’ guides, 4 advanced tips, 3 pitfalls (+ slides, sample code) </li></ul></ul>What we’ll cover
  3. 3. <ul><li>SharePoint workflows are always associated with content e.g: </li></ul><ul><ul><li>Document </li></ul></ul><ul><ul><li>Form (typically InfoPath) </li></ul></ul><ul><ul><li>List item </li></ul></ul><ul><li>Workflows revolve around tasks </li></ul><ul><ul><li>Person X must do Y </li></ul></ul><ul><li>Workflows can be started manually or automatically (i.e. when new item is added) </li></ul>Introduction
  4. 4. Introduction <ul><li>Different workflow types: </li></ul><ul><ul><li>VS workflows require coding ability (and ideally InfoPath knowledge) </li></ul></ul><ul><ul><li>SPD workflows can be powerful, but limitations </li></ul></ul><ul><ul><li>Standard workflows simple to use </li></ul></ul>Standard SPD VS COMPLEXITY
  5. 5. <ul><li>Advantages of SPD workflows: </li></ul><ul><ul><li>Built using wizard, not code </li></ul></ul><ul><ul><li>Powerful - wide-range of activities to add </li></ul></ul><ul><ul><li>Simple to deploy </li></ul></ul><ul><li>Limitations of SPD workflows: </li></ul><ul><ul><li>Can only be applied to one list at a time (no re-use) </li></ul></ul><ul><ul><li>Custom code activities, but not ad-hoc custom code </li></ul></ul><ul><ul><li>Not flexible enough for many requirements </li></ul></ul>Key decision #1 – Visual Studio or SPD?
  6. 6. <ul><li>Sequential workflow: </li></ul><ul><ul><li>‘ Traditional’ design </li></ul></ul><ul><ul><li>Generally flow downwards, but: </li></ul></ul><ul><ul><ul><li>If/else activity </li></ul></ul></ul><ul><ul><ul><li>While loop activity (cannot overlap) </li></ul></ul></ul><ul><ul><li>These aside, cannot go ‘back up’ </li></ul></ul>Key decision #2 – VS workflow type
  7. 7. <ul><li>State machine workflow: </li></ul><ul><ul><li>Series of ‘states’ e.g: </li></ul></ul><ul><ul><ul><li>‘ Awaiting initial review’ </li></ul></ul></ul><ul><ul><ul><li>‘ Awaiting final review’ </li></ul></ul></ul><ul><ul><ul><li>‘ Completed’ </li></ul></ul></ul><ul><ul><li>Can go from any state to any state </li></ul></ul><ul><ul><ul><li>Developer specifies ‘transitions’ between states </li></ul></ul></ul>Key decision #2 – VS workflow type
  8. 8. <ul><li>InfoPath or custom .aspx forms? </li></ul><ul><li>Factors: </li></ul><ul><ul><li>InfoPath forms quicker to develop </li></ul></ul><ul><ul><li>Much less complexity with InfoPath forms </li></ul></ul><ul><ul><ul><li>Custom forms must interface with workflow API manually </li></ul></ul></ul><ul><ul><li>InfoPath forms integrate with Word, Excel etc. </li></ul></ul><ul><ul><li>However, InfoPath unlikely to be suitable for public website </li></ul></ul><ul><li>See ‘collect feedback’ sample in MOSS SDK for custom .aspx forms example </li></ul>Key decision #3 – forms
  9. 9. <ul><li>Item for workflow: expenses form (InfoPath) </li></ul><ul><li>Process: </li></ul><ul><ul><li>User submits expense claim </li></ul></ul><ul><ul><li>Approved by department </li></ul></ul><ul><ul><li>Approved by finance -> Completed </li></ul></ul><ul><li>Development process: </li></ul><ul><ul><li>‘ ASPX-like’ model </li></ul></ul><ul><ul><li>Coding </li></ul></ul><ul><ul><ul><li>Drag activity from toolbox </li></ul></ul></ul><ul><ul><ul><li>Write code to tell it what to do/what values to use </li></ul></ul></ul><ul><ul><li>Deploy/test </li></ul></ul>My example – Acme Inc.
  10. 10. Acme expense workflow – first steps demo
  11. 11. <ul><li>We just hit them: </li></ul><ul><ul><li>#1: Using activities – two ways to set properties: </li></ul></ul><ul><ul><ul><li>Using code </li></ul></ul></ul><ul><ul><ul><li>Properties window </li></ul></ul></ul><ul><ul><ul><ul><li>often used to bind property to a member variable (e.g. our string CurrentLogAction) </li></ul></ul></ul></ul><ul><ul><li>#2: Deployment </li></ul></ul><ul><ul><ul><li>MS help us here – PostBuildActions.bat </li></ul></ul></ul><ul><ul><ul><li>We provide config in Feature files </li></ul></ul></ul><ul><ul><ul><li>Need to associate workflow with list(s) after each full deployment </li></ul></ul></ul>Complexities #1 and #2
  12. 12. <ul><li>How do I get at the information which was entered into the form? </li></ul><ul><li>Can write code to parse XML e.g. XmlDocument </li></ul><ul><li>Can use serialization (preferred): </li></ul><ul><ul><li>Obtain schema (.xsd) for your form </li></ul></ul><ul><ul><li>Use xsd.exe to generate class </li></ul></ul><ul><ul><li>Add class to project </li></ul></ul><ul><ul><li>Add deserialization code to workflow </li></ul></ul>Complexity #3
  13. 13. <ul><li>How do I work with SharePoint tasks? </li></ul><ul><ul><li>CreateTask </li></ul></ul><ul><ul><ul><li>Set properties in code </li></ul></ul></ul><ul><ul><ul><li>Set TaskType to 0, 1, 2 etc. to associate task edit form </li></ul></ul></ul><ul><ul><ul><li>If required, pass values to task form via ExtendedProperties </li></ul></ul></ul><ul><ul><li>OnTaskChanged </li></ul></ul><ul><ul><ul><li>In state machine should be in EventDriven activity </li></ul></ul></ul><ul><ul><ul><li>Collect values from form </li></ul></ul></ul><ul><ul><ul><ul><li>Copy to field-level vars if another activity needs to use value (e.g. IfElse) </li></ul></ul></ul></ul><ul><ul><li>CompleteTask </li></ul></ul><ul><ul><ul><li>No code required, just set CorrelationToken & TaskID </li></ul></ul></ul>Complexity #4
  14. 14. <ul><li>Always always design in Visio first! </li></ul><ul><li>Error/bug? Check the SharePoint logs first </li></ul><ul><li>Learn how to debug workflows - See ‘how-to’ in my starter pack document </li></ul><ul><li>Always rename activities so the ID makes sense </li></ul><ul><li>Write to SharePoint logs for simpler diagnostics when live </li></ul><ul><li>- Article on my blog coming soon </li></ul>Top 5 workflow tips See my starter pack for advanced tips!
  15. 15. <ul><li>SharePoint has different levels of workflow </li></ul><ul><li>Key decisions summary: </li></ul><ul><ul><li>OOTB/SPD workflow may be sufficient </li></ul></ul><ul><ul><li>Prefer state machine over sequential workflow </li></ul></ul><ul><ul><li>InfoPath forms simpler than custom ASPX </li></ul></ul><ul><li>Demo - first stage of an expense claim workflow </li></ul><ul><li>Being armed with right resources is key! </li></ul>What was he talking about??
  16. 16. Downloadable resources: http://www.sharepointnutsandbolts.com/2008/01/resources-from-my-workflow-deep-dive.html Blog: www.sharepointnutsandbolts.com LinkedIn: http://www.linkedin.com/in/chrisobrienmvp Thank you Q & A

×