Thursday, January 14, 2016

Looping Through Content in a SharePoint 2013 Site Workflow – Part 1 – Introduction

As with most things SharePoint, this seems like it should be easier. What I was trying to do seemed like a common requirement: get some data from lists in SharePoint subsites and loop through it, taking some actions on each item that meets some criteria. This post is not for the faint of heart, the new-to-workflow initiate, or the person-without-a-lot-of-permissions. We’re reaching into Office 365’s workflow guts a bit here.

In my current case, I want to check a specific list in a bunch of subsites for new items and send an email about each. I don’t want to create a separate List Workflow that sits in each of the lists because it would be an administrative nightmare to change the workflow down the road (we have over a dozen subsites, and the number will grow). Instead, I’m creating one central SharePoint 2013 Site Workflow that finds all the subsites, finds the list in each subsite (if it exists), and iterates through the items created since the last time the workflow ran. We’ll set this workflow to run every x minutes (probably once an hour).

Yes, you could do this with “code” or Powershell, but that takes it out of the hands of the Site Admin who might want to change things down the road. By using a workflow, we can give them some control over things like the text of the emails without making them learn how to code to change them.

On Office 365 in SharePoint Online, this feels a LOT trickier than it may have been in the past because of the complexity (nay, swamp) of authorization we must navigate. I expect that similar authentication issues may apply on premises, too, but Office 365 is more of a moving target.

In this series of articles, I’ll show you the steps I went through and let you know where I got stuck, waylaid, and confused. As always, I believe that only one of us should have to suffer through this stuff so that everyone else can avoid it.

This isn’t totally new ground; there are many posts out there that cover bits and pieces of this, and I’ll provide the links I found helpful and give credit where credit is due. I didn’t find anything that showed me how it all help together, though, thus this post.

Thanks right off the bat to Matt Bramer (@ionline247) and Fabian Williams (@fabianwilliams) for getting me up and rolling when I first start whinging about this.


by Marc D Anderson via Marc D Anderson's Blog

No comments:

Post a Comment