Years ago when Microsoft released it’s latest version of SharePoint Designer, it came with a few enhancements that really made building workflows with Designer more robust and efficient. One efficiency enhancement was the ability to copy actions, steps and even entire stages within the same workflow or even between workflows. Microsoft also allowed for the ability to move back and forth between stages instead of continuing down a parallel path (called a state machine workflow). While the addition of state machine workflows to Designer (previously only available in Visual Studio workflows) is great; in my opinion the best (by a very small margin) addition to Designer is the ability to call web services. As your queries get more and more complex however, knowing what is coming back into the workflow can be filled with frustration as you try to determine how to get the data from the response content. While I it isn’t a new concept, I wanted to discuss handling REST responses in SharePoint Designer workflows. Or at least how I do it. The method I use is pretty straight forward and very easy to implement.
So recently at my client site we had a report that was running incredibly long. This was a while ago, so unfortunately I can’t remember the run time, but I believe it was greater than 12 hours. The report was pretty basic, just a determination of which documents were created within the month and an output that displayed things like location, file name, created date and creator.
When reviewing the code I noticed the original solution had been coded to loop through each site in the web and then grab all the documents within a particular date range. The line in particular that scanned the documents was as follows:
var listAddedItems = listItems.Where(x => ((DateTime)x["Created"] >= reportManager.ReportStartDate && (DateTime)x["Created"] <= reportManager.ReportEndDate) || ((DateTime)x["Modified"] >= reportManager.ReportStartDate && (DateTime)x["Modified"] <= reportManager.ReportEndDate));
Pretty straight forward, but what it’s actually doing is going through and gathering all the data and throwing out what you don’t need. Not a big deal unless you are working with a lot of data. Right now we are sitting at around 1 million items in our SP farm. I think I found the culprit.
This month I traveled to Saskatoon, Edmonton and Calgary to present on the Leading Practices of Planning and Implementing a SharePoint Environment. This was not meant as a technical discussion, but instead a discussion on implementing a SharePoint environment. There is a bit of technical topics within it, but the focus is how to plan out your entire project to get the best SharePoint implementation you can. I had a lot of great discussions and questions from everyone that attended and really enjoyed myself. I promised everyone I would post my slide deck so they could reference it and use it should they choose to.
I would really like to thank the Saskatchewan SharePoint User Group, Edmonton Microsoft User Group, and the Calgary SharePoint User Group for hosting me for these presentations. I really enjoyed myself and hope to return soon with another presentation. I would also like to thank Solvera Solutions for making this all possible as well.
As promised… the slide deck.