ES Auto-Create Timesheets from Events

 

⏱️ ES ERP Automation · Server Script

Auto-Create Timesheets from Events

A scheduled ES ERP Server Script that automatically generates employee Draft Timesheets at 18:00 each day, sourced directly from the ES ERP Event Calendar — with overlap merging, billable detection, and full project traceability.

📅 Event Calendar Source ⏰ Runs Daily · 18:00 AWST 📝 Draft · Employee Submits 💰 Auto Billable Detection
18:00
Daily Run Time
7
Processing Steps
10
Field Mappings
6
Key Features
0
Manual Data Entry

Overview

This script eliminates the daily overhead of manually creating employee timesheets. At 18:00 each evening, it scans the ES ERP Event Calendar for events that occurred during the day, identifies which employees were assigned to those events, and automatically builds a Draft Timesheet for each person — pre-populated with the correct times, task, project, and activity type.

Employees receive a ready-to-review timesheet in their ES ERP inbox. They verify the hours, make any adjustments if needed, and click Submit — ensuring accountability is maintained while removing the administrative burden of manual entry.

 

 

⚙️ How It Works

01

Identify Active Employees

All active Employee records that have a linked ES ERP User account are loaded and indexed by their user email address.

02

Fetch Today's Events

All non-cancelled Events with a starts_on date matching today are retrieved from the ES ERP Event Calendar.

03

Resolve Task → Project → Customer

Each event's linked Task is looked up. From the Task, the associated Project is fetched. If the Project has a Customer set, the time log row is automatically marked as billable.

04

Map Events to Employees via Participants

The Event Participants child table is read for each event. Any participant whose user email matches an active Employee is associated with that event.

05

Merge Overlapping Events

If an employee has two or more events that overlap in time, they are automatically merged into a single time log row, with descriptions concatenated and the billable flag preserved.

06

Create Draft Timesheets

One Draft Timesheet is created per employee, containing one time log row per distinct event block. The script is idempotent — if a timesheet for that employee already exists for today, it is skipped.

07

Employee Reviews & Submits

Timesheets are left in Draft status. Each employee opens their timesheet, verifies the entries, and clicks Submit to finalise their hours for the day.

 

 

⚡ Key Features

⏰ Fully Automated Scheduling

Runs via ES ERP Scheduler at 18:00 AWST daily — no manual trigger required. The system timezone is set to Australia/Perth so the cron expression runs in local time.

✅ Idempotent — Safe to Re-run

Checks for existing Draft or Submitted timesheets before creating, preventing duplicates if re-triggered. Each employee receives exactly one timesheet per day.

🔀 Overlap Merging

Concurrent or nested events are automatically merged into a single time log row — ES ERP's overlap validation is never triggered. Descriptions are concatenated with a pipe separator.

🔒 Employee-Controlled Submission

Timesheets are created in Draft status only. Employees review and submit their own timesheets, maintaining accountability and allowing adjustment before finalisation.

💰 Automatic Billable Detection

Time log rows are flagged Is Billable automatically when the linked Project has a Customer assigned — no manual configuration required for billing classification.

🔗 Full Project & Task Traceability

Each time log row is linked to the originating Task and Project via the Event's reference fields — maintaining full project cost visibility and audit trail.

 

 

📋 Timesheet Field Mapping

Timesheet Field Source How It's Set Type
Employee Event Participants → User → Employee Matched via user_id email Auto
From Time Event starts_on Direct copy from Event field Auto
To Time Event ends_on Direct copy; defaults to starts_on + 1 hour if blank Logic
Hours Calculated Derived from To Time − From Time Auto
Description Event subject Copied directly; merged events concatenated with | Auto
Task Event reference_docname Populated when Event references a Task Auto
Project Task → project Resolved from the Task's parent Project Auto
Activity Type Default value Always set to Maintenance Work Fixed
Is Billable Project customer field Checked (1) when Project has a Customer; unchecked (0) otherwise Logic
Status Default Always created as Draft — employee submits manually Fixed

 

 

⏰ Schedule Configuration

Daily at 18:00 AWST (Australia/Perth)

The ES ERP System Settings timezone is set to Australia/Perth, so the scheduler runs in local time. No UTC offset adjustment is needed — the cron expression is used exactly as shown.

0 18 * * *
Cron Expression

 

 

📥 Installation

1
Navigate to Server Scripts

In the ES ERP Desk, go to Settings → Server Scripts → New.

2
Set Script Type & Name

Set Script Type to Scheduler Event. Name it Auto-Create Timesheets from Events.

3
Set Frequency & Cron

Set Frequency to Daily, then enter the cron expression: 0 18 * * *

4
Paste the Script

Copy the full script content into the Script field and click Save.

5
Enable the Script

Ensure the Enabled checkbox is checked. The script will fire automatically at 18:00 each day.

 

 

📝 Notes & Considerations

ℹ️

Events must have Participants. Events with no entries in the Event Participants table will not generate timesheet rows. Always assign employees as participants when creating calendar events.

ℹ️

Billable flag is project-driven. Assign a Customer to a Project in ES ERP and any timesheet rows derived from events under that project will automatically be marked as billable — no changes to the script are needed.

ℹ️

Events without an End Time default to a 1-hour duration on the timesheet. Employees should set ends_on on their events for accurate hour capture, or adjust the time log before submitting.

⚠️

Multi-day events that span midnight will generate a time log using the full raw duration. Employees should review and adjust these rows before submitting, particularly for events like vehicle or equipment out-of-service notices that run for several days.

 

 

Technical Specifications

Platform

  • ✓ ES ERP v15+ Framework
  • ✓ ES ERP v15+ Integration
  • ✓ Server Script (Scheduler)
  • ✓ Projects Module

Schedule

  • ✓ Cron: 0 18 * * *
  • ✓ Daily at 18:00 AWST
  • ✓ Australia/Perth Timezone
  • ✓ Supports Anytime Zone

Data Sources

  • ✓ Event Calendar
  • ✓ Event Participants
  • ✓ Employee DocType
  • ✓ Task & Project DocTypes

Features

  • ✓ Overlap Merging
  • ✓ Auto Billable Detection
  • ✓ Task/Project Linking
  • ✓ Draft Status (Employee Submits)

Eliminate Manual Timesheet Entry

Let your team focus on work, not admin. Auto-Create Timesheets from Events turns your ES ERP calendar into automatic, auditable timesheets — with billable detection and full project traceability.

Auto-Create Timesheets from Events — ES ERP Timesheet Automation for ES ERP Framework

© 2026 Enterprise Systems Australia | This email address is being protected from spambots. You need JavaScript enabled to view it.

Related Articles