Console Apps for SharePoint Lists

I recently had a requirement to update a SharePoint list based on a Date and Time field. The list contained two important fields: the Date and Time field called ‘Hire Date’ and a field called ‘Active’. The goal was to update the list item when the ‘Hire Date’ field was equal to today’s date and change the ‘Active’ field to false.

This is simple in a workflow, however, the item was NOT getting updated when ‘Hire Date’ was equal to today so there was no way to trigger the workflow. A simple alternative is a .NET console app that runs every day using Windows Task Scheduler.

The app itself is simple, it uses CSOM to get the values of the item and updates the Active column when appropriate.

There are several advantages to using a console app and  running it on a schedule:

  • It’s easy to parse the values of a list and preform an update
  • I don’t need to do something as unnecessary as pause a workflow on Item Creation to the ‘Hire Date’ and leave it paused for potentially weeks
  • And most importantly, I’m not using a Custom Timer Job. SharePoint Timer Jobs, particularly custom ones, can be resource intensive strains on your SharePoint server. If your SharePoint server is already strained for resources, like ours, console apps are a quick and efficient way to check for and make updates to SharePoint Lists.
Advertisements