advanced sharepoint 2013 workflow for developers
DESCRIPTION
SharePoint 2013 introduces the renewed workflow engine. In this session, you learn some advanced topics about developing workflows with Microsoft Visual Studio 2012/2013. In particular, you learn how to create custom actions to extend SharePoint Designer 2013, how to create custom workflow forms, and how to leverage the Workflow Services Manager engine to automate and manage workflows. This session targets .NET developers with a good experience in the fields of workflows development and/or process management.TRANSCRIPT
![Page 1: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/1.jpg)
SHAREPOINT AND PROJECT CONFERENCE ADRIATICS 2013
ZAGREB, NOVEMBER 27-28 2013
Advanced SharePoint 2013 Workflow for DevelopersPAOLO PIALORSI, [email protected]
![Page 2: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/2.jpg)
sponsors
![Page 3: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/3.jpg)
Something about me• Consultant, project manager and trainer• More than 40 Microsoft certification exams passed
• Microsoft Certified Solution Master – Charter SharePoint
• Focused on SharePoint since the beginning• Author of 10 books about XML, SOAP, .NET, LINQ
and SharePoint• Microsoft SharePoint 2010 Developer Reference, Microsoft Press• Microsoft SharePoint 2013 Developer Reference, Microsoft Press• Build Windows 8 Apps with Microsoft Visual C# and
Visual Basic Step by Step, Microsoft Press
• Speaker at main IT conferences
![Page 4: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/4.jpg)
Agenda• SharePoint 2013 and Workflow Manager (quick recall)• Advanced workflows with SharePoint Designer 2013• Custom actions and activities with Visual Studio 2013• Workflow Security• Workflow Forms
![Page 5: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/5.jpg)
SHAREPOINT 2013 AND WORKFLOW MANAGER
![Page 6: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/6.jpg)
SharePoint 2013 and Workflow Manager
Sharing
ContentEvents People
Vis
ual S
tud
io
Sh
are
Poin
t D
esig
ner
SharePoint 20132010 WF
_API (REST OM)
Workflow Services Manager
Service Bus
Instances Interop
Deployment
Messaging
WF Service Application Proxy
Workflow Manager
OAuth
Access Control
Work
flow
Clie
nt
![Page 7: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/7.jpg)
ADVANCED WORKFLOW WITH SPD2013
![Page 8: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/8.jpg)
Native Actions/Conditions are not enough …
![Page 9: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/9.jpg)
But something is missing …• Move File• Upload File• Search• Publish/Approve Document• Save data on a backend database• Etc.
![Page 10: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/10.jpg)
BUT WE HAVE REST APIS
Click icon to add picture
• Support XML/OData/JSON format
• Can be used to query (OData) contents
• Can be used to manage (add, update, delete) content
• Make the Client Side Object Model (CSOM) remotely available via REST
• Useful for JavaScript/jQuery consumers
• But also for workflows in SPD2013 or Visual Studio 2012/2013
JavaScript Library
Silverlight Library
.Net CLR Library
Custom Client Code
Client
Server
_api is new alias for _vti_bin/client.svc
RESTODataJSON
CSOM
![Page 11: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/11.jpg)
_api Reference
http(s)://{Host Name}/{site}/_api/{namespace}/
{object}{property}{indexer(index)}{method({parameter},{parameter},…)}
Web Application Hostname
Site Collection (Optional)
API Namespace
Operation
![Page 12: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/12.jpg)
Sample URLs• _api/web/lists• _api/web/lists/getByTitle(‘Documents')• _api/web/Lists/getByTitle('Documents')/Items • _api/web/Lists/getByTitle('Documents')/Items(4) • _api/web/CurrentUser • _api/web/SiteUsers • _api/web/getAvailableWebTemplates(lcid=1033)• _api/web/RoleAssignments/GetPrincipalId(1)/Member
![Page 13: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/13.jpg)
USING REST API FROM WORKFLOWS IN SPD2013
![Page 14: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/14.jpg)
CUSTOM ACTIONS AND ACTIVITIES WITH VISUAL STUDIO 2013
![Page 15: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/15.jpg)
Custom Activities vs Custom ActionsCustom Activity
• Custom element from Visual Studio perspective
• Minimal functional element of a workflow definition• Defined one time, reusable many
times
• Come in two flavors• Declarative: XAML• Code based: .NET Type
• Reusable in Visual Studio and in SharePoint Designer
• Complex deployment• Not available in Office 365!
Custom Action
• Custom element from SPD2013 perspective• Wraps an activity or an
aggregation of activities• Can be an Action or a
Condition• Reusable in SharePoint
Designer• Deployable through
Sandboxed Solutions• Supported in Office 365!
![Page 16: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/16.jpg)
We can create libraries of custom actions• Reusable in multiple workflow definitions• Reusable in multiple site collections• Maintainable (are based on WSP, and WSP are
upgradable …)
• Some «common» examples• Create New List/Library• Delete List/Library• Publish a document «Pending» approval• Invoke remote HTTP services (REST/JSON/OData)
![Page 17: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/17.jpg)
CREATING A CUSTOM ACTION FOR SPD2013 IN VS2013(PART 1)
![Page 18: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/18.jpg)
Creating a Custom Action (recap)• Create a Sandboxed Solution• Add a «Workflow Custom Activity»• Design the markup-based activity• You can’t use code
• Define the .actions4 file• It will be registered in the target site collection
• Package and deploy the WSP• Close SPD2013 and clear cache• C:\Users\{UserName}\AppData\Local\Microsoft\WebsiteCache\
{site}
• Restart SPD2013 and use the custom action
![Page 19: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/19.jpg)
Creating a Custom Activity (reference only)• Create a Workflow «Activity Library» project• Add a class and inherit from the proper base Activity type
• CodeActivity, CodeActivity<T>• AsyncCodeActivity, AsyncCodeActivity<T>• NativeActivity, NativeActivity<T>
• Implement .NET code• Create an .actions4 file
• It will be placed in \TEMPLATE\{LCID}\Workflow folder
• Add the assembly to the Global Assembly Cache (GAC)• Create an AllowedTypes.xml file
• %ProgramFiles%\Workflow Manager\1.0\Workflow\Artifacts• %ProgramFiles%\Workflow Manager\1.0\Workflow\WFWebRoot\bin
• IISRESET + Restart «Workflow Manager Backend» service• Close SPD2013, clear cache, restart SPD2013 and use the activity
![Page 20: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/20.jpg)
WORKFLOW SECURITY
![Page 21: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/21.jpg)
A Workflow is like an App• The workflow engine has an App Principal• You can manage app principals:
• https://{hostname}/sites/{site}/_layouts/15/appprincipals.aspx?Scope=Web
• https://{hostname}/sites/{site}/_layouts/15/appinv.aspx• https://{hostname}/sites/{site}/_layouts/15/appregnew.aspx
![Page 22: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/22.jpg)
Default permission model• By default a workflow has write only permissions• And while working leverages both• User permissions• Workflow App permissions
User Permissions
App Permissions
Workflow Permissions
![Page 23: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/23.jpg)
CREATING A CUSTOM ACTION FOR SPD2013 IN VS2013(PART 2)
![Page 24: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/24.jpg)
App Step and AppOnlySequence (recap)• You can configure a web site to «Allow workflows to use
app permissions»
• Assign «Full Control» to the workflow App Principal (appinv.aspx)
• And Trust it!
<AppPermissionRequests><AppPermissionRequest Scope="http://sharepoint/content/sitecollection/web"
Right="FullControl" /></AppPermissionRequests>
![Page 25: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/25.jpg)
WORKFLOW FORMS
![Page 26: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/26.jpg)
Understanding Workflow Forms• Every workflow definition can have• Association Form: to associate a workflow definition to a target
(0 or 1)• Initiation Form: to start a workflow instance on a target (0 or
1)• Task Forms: to provide custom UI for tasks (0 or more)
• Are common ASPX pages• Visual Studio 2012/2013 provides item templates for• Association and Initiation
• You need to manually define task forms• Leveraging custom Workflow Task content types and custom
task lists
![Page 27: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/27.jpg)
Workflow Forms and Kind of Projects• In Full Trust workflow projects• Can run server-side code (SharePoint Server Object Model)• Can do averything (they are full-trust)• Are not support for cloud-based (Office 365) deployments
• In App for SharePoint projects• Workflows are available in app-web only• In a SharePoint-hosted app-web you can run only JavaScript
code (!)• The form templates provided by Visual Studio are JavaScript
based
• You will have to interact with the Workflow Services Manager
![Page 28: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/28.jpg)
Workflow Services Manager
Workflow Services Manager
Deployment
Service
InstanceService
Subscription
Service
MessagingService
InteropService
![Page 29: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/29.jpg)
CREATING CUSTOM WORKFLOW FORMS
![Page 30: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/30.jpg)
questions?
HTTP://WWW.SHAREPOINT-REFERENCE.COM/BLOG/
@PAOLOPIA
![Page 31: Advanced SharePoint 2013 Workflow for Developers](https://reader030.vdocuments.mx/reader030/viewer/2022013114/54b7d0774a79593d748b4593/html5/thumbnails/31.jpg)
thank you.
SHAREPOINT AND PROJECT CONFERENCE ADRIATICS 2013
ZAGREB, NOVEMBER 27-28 2013