SharePoint MVP, MCM and Microsoft Press author. @resing on twitter

Code Sample Reviews–App Model Workflow

Have you checked out the SharePoint 2013 workflow samples from MSDN? I sometimes hesitate to download these because you never know the quality. Some of them don’t even compile without changes. Recently, I found a pair of examples from the Apps for Office and SharePoint Samples that do work with the RTM SharePoint 2013 and latest developer tools, one I had to tweak.

SharePoint 2013 workflow: Workflow-powered app for SharePoint

http://code.msdn.microsoft.com/officeapps/SharePoint-2013-workflow-580034f9/view/Discussions

Fixes

I had to make a few changes to get this to compile. I replaced a reference to Microsoft.Activity with System.Activity and then I had to fix the XAML for BuildDictionary based on the BuildDictionary I dragged in from the toolbox. After that it would compile against the most recent tools for SharePoint in Visual Studio 2012 on my Windows 8 box with all Windows Updates installed.

What to do after it deploys

There is no walkthrough of the functionality of this app, so I had to decipher the workflow sequence in Visual Studio to see it work. Here are the steps:

  1. After deploying, click the List1 link on the App Web default.aspx
  2. create a new item with any title
  3. refresh the page until the title is replaced with "Workflow1 is waiting"
  4. edit the item to change the text to Go workflow
  5. refresh the page until the title is replaced with "Workflow1 is completing"
  6. go back to default.aspx and click the List2 link
  7. A new item will have been created in List2 titled "Workflow1 ran on List1"

My Take

While I get that this is basically a no-code example that does a lot of stuff, I have a hard time picturing a real time scenario based on this example. The activities in the Workflow editor are fairly complicated to understand and I’m not sure I could repeat them with real data.

Despite this, it’s interesting to me. My favorite part was that I downloaded this on Windows 8, compiled it and deployed it to a free Office 365 Developer Site without touching a SharePoint Server that I had to set up or use local resources for. I also liked that it deployed in the App Model. That is super cool to me because of the removed burden on administrators to worry if this will take down the server.

SharePoint 2013 workflow: Workflow OM in an app for SharePoint

http://code.msdn.microsoft.com/officeapps/SharePoint-2013-workflow-050f5211/view/Reviews

Fixes

None. Deployed with no changes when I set the url to my Office 365 Developer Site.

What to do after it deploys

Very straightforward. Click the link to the test harness. Click the buttons to run different Javascript functions that use the Workflow Object Model

My Take

This one is interesting. It uses JSOM and sp.workflowservices.js to create a workflow. Very easy to install and use. The meat of the project is in the JavaScript functions stored directly in WorkflowOMTest.aspx.

It’s hard for me to find any other references to sp.workflowservices.js, so I’m not sure how to go deeper into this one. It would appear you can run this JavaScript from anywhere, so it could be a good example for non-SharePoint JavaScript developers.

Your take

Have you tried these examples or had better luck with the other 5 or so Microsoft has provided? Do you know of better code examples? I like to learn through experimenting with existing code like this, so I’m always looking for examples that show me how to do something new. Reply in the comments, email me resingnet-website@yahoo.com or mention me on twitter @resing.

Leave a Reply