Finally a SharePoint Designer that Developers and BAs will Love
We hit the FiveFecta with Workflows
Our horse came in, that is SharePoint Designer has given us Five winning items in this iteration of the product, our five items are
- Dictionary Object/Variable
- HTTP Service Calls
With all this you have the means to create atomic unit of work, conditional statements as well as the ability to make external calls to REST-full Service returning JSON data. The last piece of the puzzle is the addition of Visio Professional 2013 and the Stencils it brings to both author and report on the activities of the Workflow Activities.
Purpose of this Blog Post & Primer for this Post
This post well explore various usage scenarios of our Five Fecta through commentary, discussions and demo/screen shots. I am considering breaking this up into sections but perhaps it will just be one big post that covers a single solution, I’m still toying with the idea, either way its genesis is still fluid. If indeed i do break these up, I will put the various parts in this section.
Part 1 – Stages, Steps, Loops, and Visio Professional 2013
In the above post (this one) I will go about showing you the tooling and various simplistic but apropos examples designed solely to drive the usage home, in Part 2 we will use everything in a practical REAL WORLD sense
In the above post I will take a Publicly Available REST API probably the Weather API or Twitter API and use the HTTP Web Request along with the Dictionary Variable in SPD 2013 to surface it in a SharePoint Promoted Links App (List)
What’s new with Workflows
Some things that you must know about Workflows in SharePoint 2013 is that unlike SharePoint 2010 that was built on the platform of Windows Workflow Foundations 3.0 (WWF3) this version of SharePoint is built on Windows Workflow Foundation 4.0 (WWF4) and .NET Framework 4.5, it also employs a new Installer/Manager called Workflow Manager 1.0. Now you have the ability to design and create complete declarative workflows, REST and Service Bus messaging. You should also be aware that the SharePoint 2013 features and capabilities only comes available to you and your tooling after you download and install the Workflow Manger 1.0 Service and configure it to communicate with your Site Collection. For more on the Workflow Manager 1.0 please see Start: Set up and configure SharePoint 2013 Workflow Manager Finally with Visio Professional 2013 add-in provides you with a Visual Workflow Development experience both inside SPD2013 and outside inside Visio Professional 2013.
<RANT>The one thing that I have as a gripe (but I totally understand why) is that Reusable Workflows are GONE in SharePoint 2013 Workflows </RANT>
But that is somewhat disingenuous because while you certainly cannot do it in SharePoint Designer 2013 if you create your workflow in Visual Studio 2013 and make a reference to the Workflow Manager 1.0 you can attach to the GUID of the Content Type.
This is what I mean, open up SPD2013 and fire up a Reusable Workflow and you will notice that you cannot bind a Content Type that you are used to doing in SPD2010 to this Workflow
but if you change the platform to SharePoint 2010 Workflow as seen below you can change the Content Type and make a selection to bind it accordingly.
But lets get back on track.
Stages – What is it, Why do we need it, What Problem does it Solve
Stages are new and introduced into SharePoint Designer 2013 (SPD2013), a stage can accommodate any number of shapes inside Visio and Action/Activities inside SPD2013. There has to be at least one (1) stage in every SharePoint 2013 Workflow and there can only be one path in and one path out of a stage, although while inside the stage they may branch. I will provide a demonstration of that below through a parallel process. You may NOT nest stages, if you want to have nesting capability, you should use a “Step” within a “Stage” in fact it is quite neater for others to follow even from a design standpoint. As you exit a stage, you select what other stage it will transition to, and within that transition step you may also employ conditional logic to determine what path it should take as it exits the current stage. Upon completion of a workflow you should set the transition to End Workflow. Below are some examples of what I just mentioned
Stub out your Stages as a Best Practice
Now as a Object Orientated Developer that is used to Modeling/Prototyping my Classes/Modules, it is just natural for me to see ‘Stages’ in that same fashion, I first consider the ‘Start’ OR ‘End’ of what i need to do and either work forwards or backwards thinking about all the pieces that will make the effort succeed, in the same vein, when I am building a SharePoint Designer 2013 Workflow I pause to consider what my Stages will be, and HOW I will transition between them, that way once I get that thought process out of the way, I am free to just put the logic I need inside my stages and my work becomes so much easier, or at the very least, I have a plan of action that anyone can follow. One more secret about doing it that way is that I can do a Visual Layout of my Stages and take that to a Business Analyst (BA) or Business Decision Maker (BDM) and validate what I am intending to build.
Step 1: Create a Workflow (in this example I am doing a List Workflow)
Once you fill out the necessary fields and click OK, you will be taken into the Active Workflow Design pane, and a Stage will already be present and waiting for your actions.
As denoted in callout 1, we have a default stage created for us, it is called “Stage 1”, but obviously you should change that to something more meaningful, in fact, the names of Stages are by default going to be the Status Messages that you see when your workflow is Running under the Status field in the Document Library or List, so you should think carefully about how you define and layout your stages as well as the nomenclature. This is yet another reason why I elect to stub out my Stages before anything else.
In callout 2, you will see the transition to stage area where you can direct the flow of the workflow, as previously mentioned but worth calling out here:
- there is one way into a stage and one way out
- you may directly tell the stage to progressively move to another stage, or use conditional statements to drive it dynamically or End the Workflow in that area
In callout 3, you will notice Stage is grayed out, but that is because at the point of me taking the screen shot, i was in the active stage and as i mentioned before you cannot NEST stages inside stages therefore the option to create another stage was not provided.
Once you have stubbed out your Stages as I have done below, you will have something similar to what is below, notice I am showing you what a Stage Transition looks like as well as showing you in the “Wrap Up” stage, that the workflow will terminate there.
If we check out our document library we will treat it as a Bank of sorts. We will use a Document Library because it represents a slip of paper that will authorize a transaction, a Credit or Debit, so for instance
We have a Metadata Column that will hold current balance after a Credit or Debit transaction is applied. Coming back to SPD2013 now we have to set up variables to hold these values in order to do our mathematical computations ergo
Looking at Basic and Conditional Stage Transition
Now that we have Variables in place and mind you, we could have just read from the Metadata columns, but I prefer to create variables so i have an assurance of the Data Type I need to use, we will now create some logic to demonstrate how we can transition through stages. I will not go into much detail here because the idea of this exercise is to demonstrate some of the ways you can transition through stages. In the first one we will just move to a different stage, whereas in the second, we will be checking for a condition
In the above figure “1” and “3” are basically logic to take some action or capture some variables from the Current Item, your focus here is Stage Transitions. Notice in “2” we are simply just calling the Stage we need to go to, In “4 ‘we are checking to see first (a) what type of transaction this is, if it is a Debit, then.. does the individual have enough money to do what he/she wants to do, it he/she doesn’t then go to the Stage “IF Crap Hits the Fan” otherwise, if the criteria is met or this is a Credit Transaction, go to “Process Calculation” Stage.
Looking at Internal Mechanics of Stages
So, lets take a look at what can happen inside Stages, for this example we will just look at Parallel Blocks and additional Conditional Logic
So what we have in the above is an example of a Branch in a Stage, we accomplish this by having a Parallel Block  and we have two steps inside that block  which will be run in parallel. You will see proof of that via the Visio Diagram and in the Workflow History Log, and you will notice that what is inside each Step runs in ‘Sequence’ 
Next we will look at how we “Process Calculation” and “Wrap Up” Stages
In the above illustration you will see that we are not doing anything special here that we haven’t done before, we are using conditional logic in both the stage and transition step to determine the path. you will also notice I make heavy use of the Log to History action, I do this to simplify my working area but these steps can be other stages or other actions, for me I am using it to convey messages to you about what is going on.
Below are some examples of what you would expect to see under differing scenarios
Scenario 1 – Add Money to The Account
We will look at the ‘You got Paid’ ledger under the Workflow History
Above you can see that in the log that the current balance was $30, but after crediting $100 it is $130 from the prior image showing the Document Library. Now lets look at a Debit.
Now lets take out more money that they can handle and see what happens in the video below pay attention to the last entry.
Summary on Stages
Hopefully the images and video demonstrates some of what is possible when using Stages in SharePoint Designer for SharePoint 2013 Workflows. If I didn’t already say it, its worth emphasizing that Stage Names become the Status Fields by default in your Library or List being acted upon, but you can also set your own Workflow Status Message.
A more meaningful Look at Steps
So, in the example of Bank of Fabian doing Debits and Credits, you saw “Steps” being used within a Parallel Block, but I want to build on that, and show how steps can really organize your Workflow. In this scenario lets take the approach of “Opening a Bank Account” so we will need to
- Run persons Credit
- Check Source of Initial Funding for Opening of Bank Account
- Run them through ChexSystems
- Verify them against Government Regulatory Checks
- Do a Approval Process for Opening of Account
- Open the Account if they Pass all the Above, Reject if they Don’t
Now off the bat, some of these steps can be done in Parallel; I would say steps 1 through 4 can be done all at once, then we do 5 and then 6, lets look at that
Stubbed out this is what it looks like
Now if we add just a little bit of logic in there it could potentially shape up to be like the below
What does Visio Professional 2013 Bring to the Table
So, thus far we have looked at:
- Internal Mechanics
- Conditional Statements Within
- Overall Organization
- Placement and Usage
Its ample time we look at how this effort looks like Visually in Visio Professional 2013, I cannot overstate how much this is important
to both TDMs, BDMs, and the Developer/Architect. Now you can approach the problem from either end. In one hand you can have a BA or End User mock up a Visio Diagram of what the process should be like and give that to the Dev/Architect, on another hand like I do, i often will stop after I stub out the process and put in the transitions and ASK the BDM’s .. “Is this what you want?” inside the Visio Diagram which is a lot friendlier than SharePoint Designer Text Based Viewer. So based on our examples above lets move forward.
Example 1 – Bank of Fabian
What you have above is the complete process flow of the Workflow in Visio Stencil, now lets dissect it.
In the above you can see how Visio represents the shapes for SharePoint 2013 Workflows and ANYONE can do this, the stencil legend is below
The above represented the Visual Designer View which is all well and good, but there is even a simpler view that you can see that is called the Stage Outline view and that i believe you can take to anyone and they can really understand at a 10000 feet view what is going on, and you as the Developer / Architect can have some assurance you are on the right path.
End of Part 1 Summary
I am actually glad that I have broken this out, because it truly is a lot of content. It is my hope that the above illustrations, video and explanation will help you understand that it is a Brave New World out there for SharePoint Designer 2013 and this is just the scraps of it, Chicken feed, in PART 2 of this Blog, I will use what we have here and really open your eyes up on how you can make a ROBUST process engine that can make External Calls, be “State Machine – esque” and totally be NO CODE where before you certainly had to use CODE or a Third Party Product.