SharePoint 2007: Enterprise Content Management (ECM) Deep Dive Erik Mau Inetium.
Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in...
-
Upload
alyson-ball -
Category
Documents
-
view
219 -
download
1
Transcript of Minneapolis Office Developer Interest Group (MODIG) April 28, 2009 Custom Workflow Actions in...
Minneapolis Office Developer Interest Group (MODIG)
April 28, 2009
Custom Workflow Actions in SharePoint Designer
Raymond MitchellInetium
http://www.iwkid.com/
The Plan Introduction You are here Feature Presentation
Custom Workflow Actions in SharePoint Designer Next Topic Selection Random Stuff
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
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
Call for Cool Stuff Created something cool?
Send Screenshots or Videos We’ll try to feature some items here
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
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)
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
SharePoint Designer Workflows
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:
SharePoint Designer Workflows
DEMO
Out of the box SharePoint Designer Workflow
SharePoint Designer Workflows
DEMO
Behind the scenes – webpartpages.asmx??ACTIONS file
Building Custom Actions
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
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
Sign your Assembly, Deploy to GAC .snk file
.NET Framework 2.0 Configuration:
C:\Windows\Assembly
gacutil.exe Microsoft .NET Framework SDK
Create an ACTIONS file WorkflowInfo
Conditions Condition
Assembly ClassName FunctionName RuleDesigner Parameters
Actions Action
Assembly ClassName Category RuleDesigner Parameters
Create an ACTIONS file RuleDesigner
Sentence
Populate %1 with %2 %# maps to FieldBind Can be various types as defined in FieldBind
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.
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)
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>
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>
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…)
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
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!
Web.config Modifications
SPWebApplication Add (modification) Remove (modification)
SPWebApplication. WebService.ApplyWebConfigModifications()
SPWebApplication.Update()
SharePoint Designer Workflows
DEMO
Update a web.config using SPWebConfigModification
Deploying Custom Actions
Deploying Custom Actions High Level Steps:
Generate a SharePoint Solution file Web Application Scoped Feature
Feature Receiver to add web.config modifications
SharePoint Designer Workflows
DEMO
SharePoint Solution generation with Web App Feature
Custom Actions (with context)
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
SharePoint Designer Workflows
DEMO
Add 2,000 list items to a related list
Building Custom Conditions
Adding Custom Conditions Class with public static Boolean function
Same parameter options for context: WorkflowContext context string listId int listItem
SharePoint Designer Workflows
DEMO
Create a custom condition
Custom Actions on CodePlex
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
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
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
Useful SharePoint Designer Custom Workflow Activities
DEMO
Installing SPDActivitiesCreating Workflows using SPDActivities
Resources
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
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
Next Meeting Planning Possible Topics
? ? ?
Random Stuff
Raymond MitchellInetiumhttp://www.iwkid.com
Feedback Forms/Giveaway
Mingle, Eat, Feedback
See you next time!