Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in...

46
Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium http://www.iwkid.com/

Transcript of Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in...

Page 1: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Minneapolis Office Developer Interest Group (MODIG)

April 28, 2009

Custom Workflow Actions in SharePoint Designer

Raymond MitchellInetium

http://www.iwkid.com/

Page 2: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

The Plan Introduction You are here Feature Presentation

Custom Workflow Actions in SharePoint Designer Next Topic Selection Random Stuff

Page 3: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

User Group Goals Provide a community for SharePoint

Developers Share development knowledge Exchange tips/tricks/other/free pizza Add 2,000 List Items…. using a custom action

Page 4: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

User Group Format Presentations

1-2 per meeting (targeting 1.25 Hours) Hopefully Demo Heavy (Slides are for MBAs)

Highlights of Nifty Things See next slide

QA/Discussion/Random Things

Page 5: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Call for Cool Stuff Created something cool?

Send Screenshots or Videos We’ll try to feature some items here

Page 6: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Sharepointmn.com/modig/

Our current home Meeting information

Usually has the right time

Previous presentations

Running on SharePoint As required by

SharePoint User Group Law

Page 7: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Upcoming Next Meeting

July 28 (Tuesday 5:30pm) Topic: TBD – Hopefully later today Location: Based on Feedback

MNSPUG May 13 (9:00am – Noon) Topic : Business Process / Workflow/ Forms

(sharepointmn.com)

Page 8: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

The Plan Overview

SharePoint Designer Workflows Actions and Conditions How does it know?

Let’s build! Create a custom action Related: web.config modifications Deploy a custom action via Solution Build and deploy a custom condition

Would you like to know more? Custom Actions available on CodePlex Resources

Questions

Page 9: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

SharePoint Designer Workflows

Page 10: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

SharePoint Designer Workflows String together a series of action and

condition “sentences” to build a custom workflow

A number of Actions and Conditions ship with Windows SharePoint Services

Visual Designer:

Page 11: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

SharePoint Designer Workflows

DEMO

Out of the box SharePoint Designer Workflow

Page 12: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

SharePoint Designer Workflows

DEMO

Behind the scenes – webpartpages.asmx??ACTIONS file

Page 13: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Building Custom Actions

Page 14: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Adding Custom Actions High Level Steps:

Build an Activity Sign your assembly and deploy to the GAC Create an ACTIONS File Update web.config file to add an authorizedType

Page 15: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Build an Activity Activity class

(System.Workflow.ComponentModel)

DependencyProperties

ActivityValidators Add attribute to your class:

[ActivityValidator(typeof(ValidatorClassName))] Returns a ValidationErrorCollection to provide

fancy error messages in SharePoint Designer

Page 16: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Sign your Assembly, Deploy to GAC .snk file

.NET Framework 2.0 Configuration:

C:\Windows\Assembly

gacutil.exe Microsoft .NET Framework SDK

Page 17: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Create an ACTIONS file WorkflowInfo

Conditions Condition

Assembly ClassName FunctionName RuleDesigner Parameters

Actions Action

Assembly ClassName Category RuleDesigner Parameters

Page 18: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Create an ACTIONS file RuleDesigner

Sentence

Populate %1 with %2 %# maps to FieldBind Can be various types as defined in FieldBind

Page 19: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Create an ACTIONS file RuleDesigner

Sentence FieldBind

FieldBind DesignerType Field Text Id

Value Control Description Boolean Drop-down list box with the choices true and false populated.

ChooseDoclibItem Document library item selector.ChooseListItem Default.CreateListItem Default.Date Date/Time selector.Dropdown Drop-down list box control. Static items can be populated by adding Option elements.

Email E-mail advanced control. The form displays standard e-mail fields including To, From, CC, Subject and Body.

FieldNames Drop-down list box control populated with all field names in the current list or document library.

Float Text box. Allows entry of floating point values.Hyperlink URL browser. Select local or remote resources using a standard link builder.

Integer Text box. Accepts non-negative integer values.ListNames Drop-down list box control populated with all lists in the current Web site.

Operator Drop-down list box control that includes operators used to evaluate each side of the RuleDesigner sentence. Operators are static and must be added in Options elements.

ParameterNames Drop-down list box populated with all local variables that have been entered for use by the workflow.

Person Person or Group selector. You can choose only one person or group from either built-in, local users or groups or users and groups from a domain.

SinglePerson Person or Group selector. You choose only one person or group from either built-in, local users or groups or users and groups from a domain.

Stringbuilder Inline text box editor. Use to create simple strings.

Survey Default.Text Default.TextArea Default.UpdateListItem Default.writablefieldNames Drop-down list box populated either with a list of fields in the current list or a list of

document libraries that are editable. All other fields are hidden.

Page 20: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Create an ACTIONS file Parameter

Type System.String Microsoft.SharePoint.WorkflowActions.WorkflowContext System.Collections.ArrayList System.Int32 System.Boolean …

Name Maps parameter to a FieldBind

Direction (In or Out)

Page 21: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Sample .ACTIONS File<?xml version="1.0" encoding="utf-8"?>

<WorkflowInfo Language="en-us">

<Conditions And="and" Else="Else If" Not="not" Or="or" When="If">

<Condition AppliesTo="list"

Assembly="Assembly.Name, Version=0.0.0.0, Culture=neutral, PublicKeyToken=GUID"

ClassName="Fully qualified class name"

FunctionName="Boolean method nameimplemented in class"

Name="Name to be displayed in workflow editor“ Type="Advanced"

UsesCurrentItem="true">

<RuleDesigner Sentence="Sentence to be displayed to the workflow editor">

<FieldBind DesignerType="Date"

Field="Parameter that FieldBind maps to“ Function="true"

Id="Unique positive Integer“ Text="Text to be displayed as a hyperlink"

TypeFrom="Parameter that a non-Operator derives its type from“ Value="Reserved for future use">

<Option Name="Option1" Value="Value1" />

</FieldBind>

</RuleDesigner>

<Parameters>

<Parameter Direction="In" InitialValue="" Name="MyParameter" Type="System.String, mscorlib" />

</Parameters>

</Condition>

</Conditions>

Page 22: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Sample .ACTIONS File <Actions>

<Action Name="Action name displayed in editor">

<RuleDesigner Sentence="Sentence to be displayed to theworkflow editor">

<FieldBind DesignerType="CreateListItem"

Field="Parameter that FieldBind maps to"

Function="true"

Id="Unique positive Integer"

OperatorTypeFrom="Parameter Operator derives its type from"

Text="Text to be displayed as a hyperlink"

TypeFrom="Parameter non-Operator derives its type from"

Value="Reserved for future use">

</FieldBind>

</RuleDesigner>

</Default>

</Actions>

</WorkflowInfo>

Page 23: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Add an authorizedType to Web.config Add an authorizedType element to

authorizedTypes:

Very similar to safe controls, except you can’t automate it with a solution manifest (<safeControl…)

Page 24: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Web.config Modifications Should (almost) never, never, never make

changes by hand Manual changes are not “farm safe” Manual changes are not “backed up” with

SharePoint content

We need another challenge

Page 25: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Web.config Modifications Enter SPWebConfigModification

Name – UNIQUE name of the modification Xpath – path to the node being modified:

configuration/System.Workflow.ComponentModel.WorkflowCompiler/authorizedTypes

Three Types: Ensure Attribute EnsureChildNode EnsureSection

Owner Important if you want to remove later!

Page 26: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Web.config Modifications

SPWebApplication Add (modification) Remove (modification)

SPWebApplication. WebService.ApplyWebConfigModifications()

SPWebApplication.Update()

Page 27: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

SharePoint Designer Workflows

DEMO

Update a web.config using SPWebConfigModification

Page 28: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Deploying Custom Actions

Page 29: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Deploying Custom Actions High Level Steps:

Generate a SharePoint Solution file Web Application Scoped Feature

Feature Receiver to add web.config modifications

Page 30: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

SharePoint Designer Workflows

DEMO

SharePoint Solution generation with Web App Feature

Page 31: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Custom Actions (with context)

Page 32: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Adding context to your Actions Parameters that can be added:

WorkflowContext __Context Microsoft.SharePoint.WorkflowActions.WorkflowContext __Context.Web __Context.Site

These two can only be added if they are going to be used: string ListId int ListItem

Page 33: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

SharePoint Designer Workflows

DEMO

Add 2,000 list items to a related list

Page 34: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Building Custom Conditions

Page 35: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Adding Custom Conditions Class with public static Boolean function

Same parameter options for context: WorkflowContext context string listId int listItem

Page 36: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

SharePoint Designer Workflows

DEMO

Create a custom condition

Page 37: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Custom Actions on CodePlex

Page 38: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Useful SharePoint Designer Custom Workflow Activities CodePlex project -

http://spdactivities.codeplex.com

Latest release January 2008

Release contains Setup.exe and a SharePoint Solution file

Source Code is available to download or browse

Page 39: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Useful SharePoint Designer Custom Workflow ActivitiesEmail Send Email with HTTP File attachment - Allows sending emails with

attachments retrieved using a web request Send Email with List Item attachments - Allows sending list item

attachments as files attached to an email Send Email Extended - Enhaced version of the OOTB activity. Allows you to

specify the sender. Also does not break links in body.

Permissions Grant Permission on Item - Allows granting of specified permission level on a

spicified item Delete List Item Permission Assigment - Allows deleting of specified

permission level assigment for a given user Reset List Permissions Inheritance - removes any unique permissions

assigned to an item by inheriting list permissions

User Lookup user info - allows to lookup properties in site's user information list for

a given login

Page 40: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Useful SharePoint Designer Custom Workflow ActivitiesInfoPath Get InfoPath field inner text - allows to query InfoPath form data using XPath Get InfoPath field inner xml - allows to query InfoPath form data using XPath Set InfoPath field inner text - allows to change InfoPath form data using

XPath Set InfoPath field inner xml - allows to change InfoPath form data using

XPath

Other Start Another Workflow - Starts another workflow associated with a list item Copy List Item Extended Activity - Allows copying/moving list items and files

cross site.

Conditions Is User a member of a SharePoint group - Checks if a given user is part of

given sharepoint group Is Role assigned to User - Checks if a user role is already assigned on the

current list item

Page 41: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Useful SharePoint Designer Custom Workflow Activities

DEMO

Installing SPDActivitiesCreating Workflows using SPDActivities

Page 42: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Resources

Page 43: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Resources Jeff Zhang’s blog post: “Add Your Own

Custom Workflow Activities to SharePoint Designer 2007” http://tinyurl.com/c7s8yj

MSDN article: “Building Custom Workflow Conditions for SharePoint Designer” http://tinyurl.com/ca8qd6

CodePlex project: “Useful SharePoint Designer Custom Workflow Activities” http://spdactivities.codeplex.com

Page 44: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Resources SDK Document: “Importing Custom Actions

Into SharePoint Designer” http://tinyurl.com/d9vxsa

Wesley Bakker’s blog post: “Web.config modifications with a SharePoint feature”http://tinyurl.com/dlzpuw

Ted Pattison.net blog post: “Using a Web Application Feature to Modify web.config”http://tinyurl.com/ct982f

Page 45: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Next Meeting Planning Possible Topics

? ? ?

Page 46: Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in SharePoint Designer Raymond Mitchell Inetium

Random Stuff

Raymond MitchellInetiumhttp://www.iwkid.com

Feedback Forms/Giveaway

Mingle, Eat, Feedback

See you next time!