In this post I’m going to show you how to create a no server side code timer job using a SharePoint Designer 2013 site workflow.
We have a SharePoint Online (Office 365) site with a task list in it and we need to send daily alerts to users that have overdue tasks assigned to them.
The obvious solution would be to create a timer job to do that… Unfortunately we are in an Office 365 environment so we do not have the possibility to implement a standard timer job using server side code.
We can simulate the behaviour of a timer job using a Sharepoint Designer 2013 site workflow.
1. Create a New Site Workflow in Sharepoint Designer 2013
Open SharePoint Designer 2013 and create a new site workflow
2. Get All Overdue Tasks that are not Completed
In the first stage (let’s call it “Getting Overdue Tasks”) build a dictionary to store the accept header for our rest request and get results in json:
Put the current date in a DateTime variable (let’s call it “today”).
Then call the SharePoint REST Service to get the overdue tasks.
To do so insert the “Call HTTP Web Service” action in the workflow (in an App Step to avoid permission related problems).
The action url must be constructed dynamically using the “today” variable like this:
Set the action verb to GET, the request headers to the headers dictionary previously built and the response content to a dictionary to store the request result.
Get and store the returned tasks in a separate dictionary to count them and loop through them later.
3. Send Alerts to Overdue Tasks Assignees
Create a second stage (let’s call it “Sending Alerts”) to send alerts and then link the first stage to it.
Insert a loop and inside it extract the task id from the rest response and send an email to each overdue task assignees.
Use a loop index variable to address the current task and remember to initialize it to zero and increment it properly at the end of the loop.
To get the email address of the recipient (the task assignee) use the task id previously extracted from the rest response like this:
4. Wait One Day and Start Over Again
Insert a pause action and configure it to wait one day.
Link the “Sending Alerts” stage to the “Getting Overdue Tasks” stage to start over again.
Here is how the complete workflow will look at the end of the process:
Publish the site workflow and start it (you can access the “Site Workflows” page from the “Site Contents” page).
It will send the alerts daily as expected.
Does this have to be started manually?
Yes, that is the only option available for a site workflow in Office 365.
Hi Fabian. I am using this this approach to add 4 months to the current day to compare with ‘reissueDate’ held against a document in a library. I notice the action to add for months to a variable, also sets the time to 23:00. I wonder if this might impact filter (ReissueDate eq ‘variable:dateReissue’) as this returning no data for a valid HTTP code. Also with other request s I have need to apend /ListItemAllFields .. Can you see this being necessary.
Fabian, In the end I fired up Postman and successfully ran my REST call. looks like I do need to ensure my dates are in the ISO format and that I am dealing with the time part consistently $filter=(ReissueDate eq ‘2017-01-05T00:00:00Z’).
Thank you Maria for this article. Is this still the best method for creating a timer in O365 sharepoint? Also, is it still manual? Meaning someone has to click this button every day?
Yes, I think it is the easiest way to do it in Office 365 unless you want to use Azure or an On-Premise server to create a classic timer job that uses the Client Side Object Model (CSOM) to access SharePoint. It is manual in the sense that you have to start it the first time (not every day!). The site workflow should be implemented so that it waits auntil the next day (or whatever period of time you choose) before executing its logic again.
Why can’t I build the workflow for Sharepoint 2013? Only i can do it with SharePoint 2013.. What do I need? Greetings
Sorry, I want to say “Only i can do it with SharePoint 2010”.. Thank you
I have created this site workflow using a “SharePoint 2013” workflow. Why are you’re saying you cannot do it? What kind of errors/problems are you facing? Are you working in an On-Premises farm or Online? If you’re working in an On-Premises 2013 environment, have you properly installed and configured Workflow Manager? If you haven’t you will only be able to create old SharePoint 2010 workflows.
I’m guessing his 2013 workflows have not been configured by his SharePoint Nannies. (They’re not activated by default.)
I don’t see a loop that would cause the workflow to restart from the top after the Pause. So, what’s the magic that allows that to happen?
Nevermind, I see that the Transition to Stage allows for returning to the top. (Sorry, was thinking that it would only allow jumping to stages below, not above.) Thanks for posting!