Using Flow to Replace SharePoint Timer Jobs
With the increasing popularity of the cloud, more and more business are moving from legacy on-prem SharePoint to SharePoint Online. The path to SharePoint Online from on-prem can be daunting, especially if you have a lot of custom code. One of the most common code we see in legacy on-prem SharePoint environments are timer jobs.
What is a Timer Job?
A timer job is simply a task that runs at a scheduled time. SharePoint has built in timer jobs that are used to maintain and monitor the SharePoint server farm. With SharePoint on-prem, you also have the ability to create your own custom timer jobs. Some scenarios where you might create a custom timer job would be to run a daily task that checks a SharePoint list to see if a document is set to expire and if so, send an alert. Or perhaps, you need to grab some information from another data source and populate that data into your SharePoint list.
Moving Timer Jobs to O365
As you know, the development approach has changed for SharePoint Online and timer jobs are no more in O365. So, how do you move over your custom timer jobs to SharePoint Online? For a lot of cases, you can utilize Microsoft Flow to handle the task that your timer job was doing. As we mentioned before, a timer job is just a task that runs at a scheduled time. Flow offers a Recurrence Trigger which enables you to schedule a set of actions to run at a set interval (Monthly, Weekly, Daily, Hourly, etc).
For the scenario I mentioned above where you have a timer job that runs daily to check a SharePoint list for expired documents and sends an email notification, that’s really simple to set up in Flow. You could just create a new Flow with the Recurrence Trigger set to run daily. Then you can utilize the Get List Items from SharePoint function and pass in a filter to only return expired items. Finally, add a send email action and fill out the necessary information. With a few simple steps you’ve re-created your timer job in Flow!
Depending on your use case, you might not be able to re-create your timer job in Flow. Because you can’t write Full Trust Code in SharePoint Online, you are limited to the actions that you can do through the SharePoint REST API. Additionally, there are some limitations with Flow specifically such as a single user cannot create more than 250 individual Flows. Pieter Veenstra has a great blog post that highlights some of the limits within Flow which you can find here: https://veenstra.me.uk/2018/04/30/microsoft-flow-this-is-the-limit/
For a lot of the cases, Microsoft Flow can help you replace your legacy SharePoint timer jobs. For more information on Microsoft Flow check out the following resources:
Nice scenario, replace from SharePoint Timer Jobs to Microsoft Flow. 😄