1 / 46

Minneapolis Office Developer Interest Group (MODIG)

Minneapolis Office Developer Interest Group (MODIG). Raymond Mitchell Inetium. April 28, 2009 Custom Workflow Actions in SharePoint Designer. http://www.iwkid.com/. The Plan. Introduction  You are here Feature Presentation Custom Workflow Actions in SharePoint Designer

clove
Download Presentation

Minneapolis Office Developer Interest Group (MODIG)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. The Plan • Introduction  You are here • Feature Presentation • Custom Workflow Actions in SharePoint Designer • Next Topic Selection • Random Stuff

  3. 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

  4. 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

  5. Call for Cool Stuff • Created something cool? • Send Screenshots or Videos • We’ll try to feature some items here

  6. 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

  7. 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)

  8. 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

  9. SharePoint Designer Workflows

  10. 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:

  11. SharePoint Designer Workflows DEMO Out of the box SharePoint Designer Workflow

  12. SharePoint Designer Workflows DEMO Behind the scenes – webpartpages.asmx?? ACTIONS file

  13. Building Custom Actions

  14. 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

  15. 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

  16. Sign your Assembly, Deploy to GAC • .snk file • .NET Framework 2.0 Configuration: • C:\Windows\Assembly • gacutil.exe • Microsoft .NET Framework SDK

  17. Create an ACTIONS file • WorkflowInfo • Conditions • Condition • Assembly • ClassName • FunctionName • RuleDesigner • Parameters • Actions • Action • Assembly • ClassName • Category • RuleDesigner • Parameters

  18. Create an ACTIONS file • RuleDesigner • Sentence • Populate %1 with %2 • %# maps to FieldBind • Can be various types as defined in FieldBind

  19. Create an ACTIONS file • RuleDesigner • Sentence • FieldBind • FieldBind • DesignerType • Field • Text • Id

  20. 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)

  21. Sample .ACTIONS File <?xmlversion="1.0" encoding="utf-8"?> <WorkflowInfoLanguage="en-us"> <ConditionsAnd="and" Else="Else If" Not="not" Or="or" When="If"> <ConditionAppliesTo="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"> <RuleDesignerSentence="Sentence to be displayed to the workflow editor"> <FieldBindDesignerType="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"> <OptionName="Option1" Value="Value1" /> </FieldBind> </RuleDesigner> <Parameters> <ParameterDirection="In" InitialValue="" Name="MyParameter" Type="System.String, mscorlib" /> </Parameters> </Condition> </Conditions>

  22. Sample .ACTIONS File <Actions> <ActionName="Action name displayed in editor"> <RuleDesignerSentence="Sentence to be displayed to theworkflow editor"> <FieldBindDesignerType="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>

  23. 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…)

  24. 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

  25. 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!

  26. Web.config Modifications • SPWebApplication • Add (modification) • Remove (modification) • SPWebApplication. WebService.ApplyWebConfigModifications() • SPWebApplication.Update()

  27. SharePoint Designer Workflows DEMO Update a web.config using SPWebConfigModification

  28. Deploying Custom Actions

  29. Deploying Custom Actions • High Level Steps: • Generate a SharePoint Solution file • Web Application Scoped Feature • Feature Receiver to add web.config modifications

  30. SharePoint Designer Workflows DEMO SharePoint Solution generation with Web App Feature

  31. Custom Actions (with context)

  32. 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 • intListItem

  33. SharePoint Designer Workflows DEMO Add 2,000 list items to a related list

  34. Building Custom Conditions

  35. Adding Custom Conditions • Class with public static Boolean function • Same parameter options for context: • WorkflowContext context • string listId • intlistItem

  36. SharePoint Designer Workflows DEMO Create a custom condition

  37. Custom Actions on CodePlex

  38. 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

  39. Useful SharePoint Designer Custom Workflow Activities Email • 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

  40. Useful SharePoint Designer Custom Workflow Activities InfoPath • 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

  41. Useful SharePoint Designer Custom Workflow Activities DEMO Installing SPDActivities Creating Workflows using SPDActivities

  42. Resources

  43. 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

  44. 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

  45. Next Meeting Planning • Possible Topics • ? • ? • ?

  46. Random Stuff Raymond Mitchell Inetium http://www.iwkid.com Feedback Forms/Giveaway Mingle, Eat, Feedback See you next time!

More Related