Search for Help
< All Topics


This script monitors Timesheets for any status change and performs various notification actions, depending upon a timesheet’s previous status and its new status

Where to Find It

Name of runbook: TimesheetStatusNotification

The script is under source control and can be accessed from the following repository:

Speakeasy Azure Runbook Repository

See the following article which provides an overview, inccluding how to make changes to scripts using git:

See the following document (advanced users only!!) regarding how the script was initially created in the Azure environment: Creating a PowerShell script in Azure

This script is scheduled to run using schedules which can be viewed via the following link: TimesheetStatusNotificationSchedules. At the time of writing, each schedule runs hourly: one runs on the hour and the other on the half-hour. This ensures that the script runs every half-hour. This approach is necessary because Azure runbook schedules have a  minimum frequency of one hour. The script generates a log file which can be checked for errors. This can be seen here: TimesheetStatusNotification log files

How it Works

The script reads the “Timesheets” Sharepoint list and retrieves those list items where the modified date is greater than the last time the script was executed. For each changed item, the script checks if the status column value has changed and performs different actions. e.g. if the previous timesheet status was “Not Submitted” and the new status is “Awaiting Approval”, an email is sent to a distribution list (Timesheet Reviewers) to tell them, so that they can check the timesheet entries and approve the timesheet. Take a look at the script for more details of what actions are taken.
The statuses are read from a “TimesheetStatusHashMapAsString” Azure environment variable – see Azure Environment Variables. Once actions have taken place, the timesheet statuses are written back to this variable. Similarly, a time value is written to the  “lastTimesheetChangeTime” variable – it is this value that is used to determine the last time the script was executed.
For testing purposes, the “Create Monthly Timesheet Entries” script generates a timesheet entry for Paul Cashmore in addition to creating entries for staff members.
The Timesheet status notification script is configured so that, if any change is detected in the status of Paul Cashmore’s timesheets, only Paul Cashmore is emailed. This enables Paul to test the Timesheets app and associated functions without other user’s receiving email notifications.