Finally a SharePoint Designer that Developers and BAs will Love 28


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

  1. Stages
  2. Loops
  3. Steps
  4. Dictionary Object/Variable
  5. 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

Part 2 – Put it all together with HTTP Service Calls via REST and the Dictionary Object/ Variable

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

image

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.

image

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)

SNAGHTML7544272

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.

SNAGHTML959168

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.

image

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

image

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

image

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

image

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

image

So what we have in the above is an example of a Branch in a Stage, we accomplish this by having a Parallel Block [1] and we have two steps inside that block [2] 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’ [3]

Next we will look at how we “Process Calculation” and “Wrap Up” Stages

image

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

image

We will look at the ‘You got Paid’ ledger under the Workflow History

image

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.

image

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

  1. Run persons Credit
  2. Check Source of Initial Funding for Opening of Bank Account
  3. Run them through ChexSystems
  4. Verify them against Government Regulatory Checks
  5. Do a Approval Process for Opening of Account
  6. 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

image

Now if we add just a little bit of logic in there it could potentially shape up to be like the below

image

What does Visio Professional 2013 Bring to the Table

So, thus far we have looked at:

  • Stages
    • Internal Mechanics
    • Transitions
    • Conditional Statements Within
    • Branching
  • Steps
    • Overall Organization
  • Loops
    • 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

image

What you have above is the complete process flow of the Workflow in Visio Stencil, now lets dissect it.

Stages Breakdown

image

 

image

image

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

image

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.

image

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.

 

Stay Tuned…


Leave a comment

Your email address will not be published. Required fields are marked *

28 thoughts on “Finally a SharePoint Designer that Developers and BAs will Love

  • Christie

    This is wonderful – I’m new to 2013 and had been just “winging it” this great post explained those stages/transitions perfectly. Thank you!

  • Azam Javaid

    Hi Fabian

    Many thanks for the post…very useful.

    I am using stages in a workflow I have created to transition between states i.e. Checking Keywords, Move Document, etc. One thing I have noticed is that with Version History turned on each stage creates a new version of the item/document. I only want it to create a new version once the workflow completes (as is the case in 2010). Any ideas how I can do that? Is this correct functionality or a bug?

    Thanks again.
    Azam

    • fabiangwilliams

      I haven’t tried it with Versioning turned on, but versioning does create a new .minor version of a document everytime it is opened and saved. you may need to look at your approach, that is by design.

      • ayeshaijazkhan

        Thanks Fabian.

        I am not actually opening and saving the document. All I do is transition between stages based on certain conditions and that is creating a new version (major or minor – depending on how versioning is setup). So for example:

        Stage 1: Get configuration settings

        Stage 2: Check Keywords

        Stage 3: Processing Complete

        Each one of these stages creates a new version of the document even though none of them are saving the document. Actually did a test. I created two empty stages, with the first transitioning to the second. Both stages created versions of the document even though there were no actions in the stages. It is very bizarre.

        Thanks
        Azam

        • fabiangwilliams

          Ok, that is Bizarre 🙂 so I have not tried that yet, but when I get the spare time I will, that seems like a good blog post to find out why… Cant say ive heard that before, especially when you say that the “Stages” are blank and just transitioning from one to the next. Since I don’t know your Environment, I will try it out on my own. so to clarify, if you have 3 stages and you have versioning turned on, and stage 2 and 3 have nothing in them except to transition from one to the next.. you say 2 more versions of the document are created… if that is so, I will test it out myself and see what I can come up with to tell you based on my results. Im buried on two projects now with a deadline so I may not get to it easily. if we are following each other on Twitter please DM remind me, if we are not, just Public Tweet me and reference this blog post comments so I remember. give me a few days

          • Azam Javaid

            Hi Fabian, that is correct. I’ve tried this on two environments, my own dev and also a client and the result is the same. I will check if I am following you on Twitter, I should be.

            Thanks
            Azam

            ps. apologies the comment was from ayeshaijazkhan, it’s a friend I was helping.

  • Sonia Elizabeth Soriano

    I have a question about using custom developed actions to use in workflow 2013 platform, if there is a way for them to work also in workflow 2010 platform but on SharePoint 2013? or do I have to implement the custom action again to for it to work in wokflow 2010 platform?

    • fabiangwilliams

      although i have not tried what you are saying, it is my belief that you will need to do it over. I say this because even the Activities OOB are different based on which Method of WF you choose going into SPD. As well, the engine is different, Azure Workflow Manager for SP13 and SharePoint for SP2010. Let me know what you find out, but this what i think. If i find out different I will post back here and let you know.

  • SivGee

    Greate Article Fabian! Thqs much for putting it together.

    I have Visio Professional Installed. When I try to export my SPD 2013 workflow, I get a blank visio drawing generated with start and end actions. And whenI try to change to visio designer view, i get a blank visio designer. Any idea on what I might be missing?

    Thanks

    • fwadmin Post author

      Ive seen this intermittently even when I have visio installed. it sometimes is when you have errors, well not really errors as much as they the way you have your activities chained together is not consistent to how visio wants to see it.

      • SivGee

        Thanks Fabian!
        That’s probably it. Then my question would be – If Visio export might not work at all times, then what are the best practices for backing up workflows and restoring on different sites?

        Another unrelated question – We recently applied SP1 upgrade on our SharePoint VM and all the workflows started to throw errors below. (Not sure if its the SP1)
        ‘Failed to load this workflow. To correct this problem, restart SharePoint Designer.’ Hit f5 then see this error ‘Windows Workflow Foundation, part of .Net Framework 3.0, must be installed to use this feature.’
        Cleared cache :%APPDATA%MicrosoftWeb Server ExtensionsCache & %USERPROFILE%AppDataLocalMicrosoftWebsiteCache and re-registered workflow to the site collection and all worked fine for few days. Now these errors are coming back on 1 specific workflow which has multiples(5) stages,Steps and Rest calls. But do not exceed the workflow limitations that Microsoft has provided. Also, I did not receive any alerts on errors in the workflow while saving or publishing it.
        I tried to open the xoml for the current version and tried to remove recent changes (thinking something went corrupt) and copied them over to a new workflow. SPD still didn’t like it. I had to restore a much older version by copying XOML over and redo 3 days of work. Have you heard of or experienced this before? Wanted to know your thoughts on what could have possibly gone wrong.

        • oroboros

          SivGee,

          This is happening to me, as well. Clearing the multiple caches does not help. Any workflow past a certain complexity, especially with multiple WF Tasks, inevitably leads to this “Windows Workflow Foundation, part of .Net Framework 3.0, must be installed to use this feature” error. At this point the WF is lost and irretrievable.

    • fwadmin Post author

      possibly because you targetted a SharePoint 2010 WF experience rather than 2013, which could mean that your 2013 WF Manager 1.0 and Service Bus install is not done properly or you didnt run the POSH script to bind the WF Manager to SharePoint Site

  • Shaz

    Hi. I would like to know whether the sharepoint workflow can be initiated manually at each stage.
    E.g. I manually start workflow when i create an item… Then I activate it.. It goes to someone else.. The other person modifies, then activates the workflow manually for it to go to the person coming after him.. Is that possible?

    Thanks,

    • fwadmin Post author

      I am not sure I quite understand, but if you want the WF to pause until an event happens, that is possible via pause until time/date or you can have a field set during that pause duration and do conditional logic to check thereafter. if that wont work for you then you can have multiple WF that works on item created and on item updated. if that does not work, then you can do event receivers.

  • joão antunes

    sharepoint 2013 sucks in workflows. lots of actions removed or with reduced functionality. AD stuff, permissions, “wait for var” stuff, etc. i hope microsoft will implement again them for 2013 but i doubt that will happen. sharepoint workflows are good for demos and simple functionality, not for real world needs.

  • Anna

    Hello Fabian, very informative post.

    I have a question relating to SharePoint 2013 Reusable in designer.

    Question is that I want to access the library columns in that workflow, is there any way to do that?

    • fwadmin Post author

      Yes, absolutely, if it is a list workflow they are natively available from Current Site dropdown if a Site Workflow you still can. You can also tap into the Workflow columns as well.

  • Shar

    Hi Fabian

    Do you have an example/are you able to help with adding a link (content type is link to document) to a document library using rest services and SharePoint Designer 2013?
    Thanks
    Shar

    • fwadmin Post author

      I have not tried it to be honest, but the same principle i have outlined in other post should still be germane. if you have a specific error perhaps i can be of more help