Module 9 - Workflow

  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Module 9 - Workflow as PDF for free.

More details

  • Words: 1,050
  • Pages: 26
Module 9: Workflow

Overview 

  

Workflows in Microsoft SharePoint Products and Technologies Workflow Life Cycle Building Custom Activities Building Custom Workflow Templates by Using Microsoft Visual Studio

What Is a Workflow?  



Long Running : Days, Weeks, Months, Years Serializable: Doesn’t have to be running the whole time Resumable: Can be restarted when necessary

SharePoint and Workflow 



SharePoint is a:  Persistence Engine – You don’t have to worry about where the workflow is stored  User Interface – Interact via the Web or through Microsoft Office system integration Workflow brings process to SharePoint data

Differentiating Event Handlers and Workflow Event Receiver  

 

Lightweight Short Running Automatic Initiation No User Interface

Workflow  





Robust Long Running Automatic or User Initiation Optional User Interface

Non-Developer Workflow Options 

Out-of-the-Box Templates  Three Templates: Three State, Approval, Collect Feedback  Easy to use but flexibility is limited



SharePoint Designer  Easier to build than workflows with Visual Studio  Limited rules-based engine  Can not be moved between sites or between environments (not reusable)

Workflow Life Cycle Developer develops a workflow template

Developer wraps workflow template in Feature and Solution

Farm administrator deploys the workflow solution

User or event starts a workflow instance

Administrator creates a workflow association with a list or content type

A Site Collection administrator activates the workflow feature

Workflow executes activities and optionally creates tasks and history items

Optionally, the workflow owner modifies the running workflow instance

Workflow completes

Workflow Forms 







Association – When the workflow template is associated with a list Instantiation – When a workflow instance is started Workflow Modification Form – When the user wants to modify the flow of a running workflow Workflow Status Form – The form displayed to the user to indicate the status of a workflow

Content Types and Workflows  



Workflows can be associated with a content type Workflow Tasks are a special content type (0x010801) Content Types can have special new, display, and edit forms  Therefore, the task edit page for a workflow task can be customized

Development Environment 



Microsoft Visual Studio 2005  Windows Workflow Foundation Extensions for the design experience  SharePoint Workflow Project templates Microsoft Visual Studio 2008  Microsoft Visual Studio Tools for Microsoft Office 2008 delivers a workflow project template Automates deployment and activation

Components of a Workflow   

Simple Activities – Does something Composite Activities – Coordinates other things Custom Code (via Simple Activities) – Does everything else

Simple Workflow Activities 

An activity is:  An atomic set of instructions used to complete a unit of work  A reusable component used to compose workflows



Activities are like controls in forms development  You drag and drop them onto a design surface  You modify their properties with property sheets  You generate event handlers and write code inside

Common Composite Activities    

If Else While Sequence Parallel

Writing Code in the Workflow 



Code Activity  Contains one method to execute—thus providing a way to plug code directly into a workflow Custom Developed Activity  Derive from the Activity class, override the Execute method, and deploy to the Global Assembly Cache (GAC)

The Workflow Project 

Sequential Workflow  Predictable and fixed path for the workflow  Move from one activity to the other, possibly branch but flow is predefined



State Machine Workflow  Event-driven workflow  Events control the execution of the activities

Model the Workflow     

Drag and drop activities on the design surface Service activities Event activities Code activities Activities to branch the workflow

SPWorkflowActivationProperties 

Delivers SharePoint context information to your workflow code  Property bound to WorkflowProperties property of OnWorkflowActivated event activity



Access item information public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties(); public double TotalAmount = 0; private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e) { TotalAmount = Convert.ToDouble(workflowProperties.Item["Total"]); }



Process association and initiation data

Branch the Workflow 

Define Rules  Code condition  Declarative condition

Code Activity  

Basically empty activity Connect your event handler executing custom code

private void SetApproved_ExecuteCode(object sender, EventArgs e) { workflowProperties.Item["ReportStatus"] = "Approved"; }

Model of the Workflow   



CreateTask activity WhileActivity OnTaskChanged activity CompleteTask activity

Preparing a Task 

Item based on Workflow Task content type  Inherits from Item content type  Additional fields to store workflow information  Event handlers



Hook up your own code with the event handlers and  Assign an ID  Set the properties of the task item private void createTask1_MethodInvoking(object sender, EventArgs e) { Task1Id = Guid.NewGuid(); Task1_Properties.Title = string.Format("Expenses of {0} to Approve", workflowProperties.Item["Name"].ToString()); string managerEmail = workflowProperties.Item["ManagerEmail"].ToString(); string manager = workflowProperties.Web.AllUsers.GetByEmail(managerEmail).LoginName; Task1_Properties.AssignedTo = manager; }

While Loop 



Code condition  Class-level variable in code is set to true if manager completes the task (setting percentage complete to 100%) Exit the loop when condition is false

private void IsWaiting(object sender, ConditionalEventArgs e) { e.Result = !taskCompleted; }

Workflow Forms 

Forms are used for configuring, initiating, and modifying workflows and completing tasks  Association Form, Initiation Form, Modification Form, and Task Edit Forms



ASPX Forms  Can be used by Windows SharePoint Services and Microsoft Office servers  Server-side only



InfoPath Forms (SharePoint Server or Microsoft Office Forms Server)  Server rendered by Microsoft Office Forms Server  Microsoft Office client integration  Write once, run server and client (same form)

ASPX Pages 

Replace Windows SharePoint Services ASPX pages with custom ASPX pages in workflow feature

<Workflow Id="4797A6A6-4F31-40ca-9814-746402C2DB56" Name="Litware Approval" Description="Sample workflow template demonstrating workflow input forms" CodeBesideClass="LitwareWorkflows.LitwareApproval" CodeBesideAssembly="LitwareWorkflows, Version=1.0.0.0, Culture=neutral, PublicKeyToken=74bad7277fe0d19e" AssociationUrl="_layouts/Litware/LitwareApprovalAssociation.aspx" InstantiationUrl="_layouts/Litware/LitwareApprovalInitiation.aspx" ModificationUrl="_layouts/Litware/LitwareApprovalModificationForm.aspx" TaskListContentTypeId="0x0108010084565D92BEFE4a75A28C2F658B7BECCA" > <MetaData> <Modification_c7a53c4e-ab25-450f-a595-ae2b380d7c3e_Name> Modify workflow instance with a custom Litware form

Typical Flow of Creating ASPX 



Create ASPX with code-behind  Note that you have to manage all of the interaction between your page, Windows SharePoint Services, and the workflow engine  E.g., Creating the association, starting the workflow, serializing the data Deploy ASPX in 12\Template\Layouts folder

Review 

  

Workflows in Microsoft SharePoint Products and Technologies Workflow Life Cycle Building Custom Activities Building Custom Workflow Templates by Using Microsoft Visual Studio

Related Documents

Module 9 - Workflow
April 2020 10
Dbf T Module Workflow
November 2019 10
Module 9
May 2020 11
Module 9
December 2019 15
Workflow
October 2019 32
Workflow
November 2019 32