1

I have a couple of sharepoint online lists which have a custom column named "Project Due Date" of type Date-time. Now i want to run a scheduled job on daily basis (12:00 am) which will check if the "Project Due Date" is within next week, and send an email to a group of users inside a SharePoint group accordingly. then after sending the email, to update a checkbox inside the list item indicating that an email has been sent (to avoid duplicate emails on next day).

if i am inside a SP-Onpremises environment, i will do this by creating a console application + schedule its execution using windows tasks scheduler.

but inside sharepoint online, what are the best appraoch to achieve this? Thanks

  • for the user who request to close this question.. now i am NOT asking for opinions i am asking about appraochies... – john Gu Sep 5 '18 at 15:18
  • 1
    Have you considered using workflows? You can have the workflow pause for x days, so you'll have to calculate how many days to pause the workflow. The only thing is, this approach wouldn't send emails at midnight but the time the item was created. I would personally use the approach in @Sergei's answer (in fact I've got a few jobs I've been running for years with no issue) but figured I'd give you an alternative. – wjervis Sep 5 '18 at 16:56
  • @wjervis i heard before about Pause Until inside workflow, but i read that they have many drawbacks, such as modifying the date will not get reflected. now i am not sure if this have been improved in SP online. if i find an appraoch to achieve what i am looking at using workflows, then this will remove the headache of developing and hosting the console application . could you advice more on your choice of using workflow? is this appraoch reliable ? and will it be capable to handle modifying the Due Date?? also does pause until means the item can not be edited (the item is paused)? – john Gu Sep 5 '18 at 22:35
  • I'd not recommend workflows for this scenario. I just figured I'd mention it as a last-ditch alternative. As you say, there are flaws with this approach that aren't worth the effort. I'd personally go with an Azure Job, as suggested by Sergei. – wjervis Sep 6 '18 at 11:32
3

You should run your job in any cloud-based service, which supports scheduled runs. It might be AWS (Amazon Web Services) or Azure. Azure is a better choice because it's .net based, Microsoft backed, has a lot of convenient SDKs and this approach is proven by many SharePoint developers\companies.

In Azure you have two options: go with Azure Function or with Azure web jobs.
Azure jobs have a higher cost in comparison to Azure Functions.

Azure Functions have a free tier, which gives you approximately 100hours with 1GB memory or 200 hours with 512MB of memory per month for a function running 1 sec or 3.3 hours with 512MB of memory per month for a function running 1 minute. An Azure function can't run more than 10 minutes, that's a drawback. If there is a chance, that your timer jobs run more than 10min, then go ahead with Jobs.

For Azure Jobs you have to select always on mode, which will cost at Basic level approx. 50$ per month.
In general, if money doesn't matter I suggest using jobs for such tasks. Why? Because Functions are more for serverless approach, with different triggers and dynamic flows. Also, Web Jobs sdk a lot more stable and friendly. Azure Functions are still changing some things, which might be confusing at start.

Must read articles - PnP remote timer job framework

One another approach through using your own on-premises infrastructure, which has internet access. However I believe it's even more difficult and costly to implement than cloud-based solution.

  • 1
    Yes, in both Functions and Jobs you are able to run a .net code, which sends rest api queries. and do almost whatever you want. For #2 - I meant Azure functions pricing. You can select how many memory your function uses, based on memory total price will be calculated. Check out Azure pricing calculator - add Azure Function, select memory size, number of executions and see your total price. Very handy tool. – Sergei Sergeev Sep 5 '18 at 16:25
  • 1
    function.json is a requirement for azure functions, this file describes essential parts and some configuration of a function. There is no UI for building schedule, however, azure funcs use cron scheduler, so you can use any online cron expression builder. – Sergei Sergeev Sep 6 '18 at 18:06
  • 1
    Checkout this article or search similar – Sergei Sergeev Sep 6 '18 at 18:26
  • 1
    right, this SO answer even better. Try with something really simple first, like Console.WriteLine in your console app, just to make sure everything works at the minimal level of code – Sergei Sergeev Sep 6 '18 at 18:32
  • 1
    it's not an issue, just use upload your console as-is – Sergei Sergeev Sep 6 '18 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.