What is Office 365 Dev PnP

Dev PnP is a joint development program for some of Microsoft Enterprise customers for helping them to move from farm solutions to add-in Model. Real life experiences and work done with the customers has been really the fundamental source for many of the approaches introduced for broader community using Office 365 Developer Patterns and Practices (PnP).

PnP Provisioning framework is a template based platform for provisioning site collections. Template based model allows you to save an existing site design as a provisioning template and the framework will provision the site based on this template. Alternatively you can manually define your template in XML based on the PnP Provisioning Schema. You can extend the provisioning engine by using custom extensibility providers using CSOM/REST interfaces.

How PnP Provisioning Engine Works

The main idea of Provisioning engine is provision site collection and subsites by applying a provisioning template to a target site.  Below are the steps involved while provisioning a site

  • Create a Site collection based on the Empty Site Template (Provided by PnP) and apply Some customizations to this Site collection
  1. Theming and Branding
  2. Add new Lists and Content Types
  3. Add Web parts
  4. Add required Assets (Scripts/CSS/Images etc)
  5. Add Some Workflow to this site

Your site is up and running with these new customizations

  • Once your changes are done, Go to Site Actions and Site Settings -> Save Site As Provisioning Template, which will create on record in the Azure Storage
  • Azure job will create XML based template corresponding to this Site and store that template in Infrastructure site.
  • Now if you can use this template for provisioning the target site, Select this template and provide the required parameters. A record will be create in Azure storage
  • Azure job will read that record and start provision the site based on this template.

You can browse the site and see whether the target site was provisioned or not based on the template created from existing source site. More information about site provisioning process is available here

Why Workflows

Across the organization teams use sharepoint to collaborate on documents and share information. Workflow is an automated flow chart that takes care of lot of labor, guesswork and randomness out of your standard work processes.

Consider a scenario like help desk management system, running this process manually mean a lot of checking up and keep track of tickets table, sending reminders for approval and escalations if things are not moving to the next level. Each of these tasks has to perform by n number of persons which led to n number of interruptions.    If you have workflow defined in place to run this process all these things are taken care by workflow which minimizes the human intervention and productivity will be very high.

You do not want to write a single line of code but want to improve team productivity and efficiency, this is where workflows comes into the picture.

Integrating SPD Workflows in DevPnP

Suppose you want to create a workflow for expense management system in your organization. The typical process involved here is

  • User Submits the bills, mail is trigger to the manager(1st level) for approval/rejection
  • Upon mail notification manager(1st level) either rejects/approves the bills
    • If Manager(1st level) approves ticket, it will be send to second level approval i.e. Finance Manager, the corresponding notification will be send to both Second level Manager and the User
    • If Manager rejects, ticket will be closed and notification will be send to the user with the necessary details
  • Upon mail notification manager(2nd level) rejects/approves the bills
    • If manager approves ticket will be closed and notification will be send to user
    • If manager rejects, ticket will be update with the status and notification will be send to the user with the necessary details.


How to simulate this workflow in SPD 2013

To develop this workflow, create a State Machine Workflow and create various states based on the requirement.

Unfortunately there is no comments column in the existing Approval Workflow provided by sharepoint, so we customized the existing workflow and corresponding screen shots are provided at the end of the document.

SPD Workflow Creation Steps:

  • Add a custom content type and column : ExpensecontentType and Expense Comments
  • Add this content type to existing workflowtask content type
  • Crate a state machine workflow with number of stages
  • Publish this workflow to the site collection
  • Save this site as a template and the below are the corresponding schema changes will happen in DevPnp
    • Xaml file will be created with the necessary XML definitions based on the workflow under infrastructure site.
    • In site template the corresponding .xaml file will be referenced under <pnp:WorkflowDefinition Id=”9e08586c-85bf-4b85-873b-916e4bfcb9c3″ Description=”ExpenseWorkflow” DisplayName=”ExpenseWorkflow” InitiationUrl=”” Published=”true” RequiresAssociationForm=”false” RequiresInitiationForm=”false” RestrictToScope=”{listid:Expense}” RestrictToType=”List” XamlPath=”9e08586c-85bf-4b85-873b-916e4bfcb9c3.xaml”>SharepointWorkflow_1
    • Workflow related lists and content types are created in site template.SharepointWorkflow_2

This is how the Expense workflow works






Workflow drives the process which brings team efficiency and productivity, so that the team can focus on doing the work rather than managing the workflow. No single line of code is required to create the workflow, you need to simply create different states and rules in designer and publish the changes to Site collections. It is very easy to extend and integrate workflows by using Office 365 DevPnp.