Form Scripts - User Guide
These scripts run in the background when you Submit or Approve a form to ensure data is clean, valid, and correctly recorded in the system.

There are three types of Generic Scripts available currently:
- Job Costing Scripts
- Rental Wet Hire Scripts
- Payroll Timesheet Scripts
Additional scripts and script types will become available in time.
Job Costing Scripts

Scripts: GenericJobCostSubmit & GenericJobCostApprove
What do these scripts do?
These scripts take the time and materials entered on a form and "book" them against a specific Job. The scripts are triggered by the Form Status.
On Submit: The script checks your math and creates a draft (Unapproved) entry.
On Approve: The script finalizes the entry as Approved.
How does it work?
When a user fills out a Daily Log or Timesheet, the script follows this logic:
It checks your "Mode":
It looks at the Sub Form Field setting. If you selected a sub-form template, it only looks at the rows in that sub-form. If not, it looks at the main form details.
It cleans up old data:
If you edit a form and re-submit it, the script intelligently deletes the old lines for that specific form and resource, before creating new ones. This prevents duplicate entries.
It calculates specific costs:
It validates the Job, Resource (Labour or Plant), and Cost Type.
It enforces time rules:
It calculates Duration as: (End Time - Start Time) - Lunch Break.
Overnight Logic: If you enter a Start Time of 10:00 PM and an End Time of 2:00 AM, the script automatically assumes the End Time belongs to the next day.
Common Blockers
The script will stop the form from submitting if:
The Math doesn't add up:
If you listed 3 specific activities (e.g., "Framing: 2 hours", "Cleanup: 1 hour") but the total time difference between Start and End is only 2 hours, the script will fail. Total Duration must equal the sum of Activity Durations.
Missing Master Data:
You cannot type in a Job name or Employee name manually; they must be selected from the dropdowns and exist in the database.
Rental Wet Hire Scripts
Scripts: GenericRentalWetHireSubmit & GenericRentalWetHireApprove
What do these scripts do?
"Wet Hire" refers to renting a machine plus the operator. These scripts ensure that every time a piece of equipment is logged, there is a valid operator attached to it.
How does it work?
This script is smarter than a standard log; it distinguishes between people and machines automatically.
Is this Labour or Plant?
If you select a Plant item, the script treats the entry as Equipment. It requires you to also select an Employee (the operator).
If you only select an Employee (and no Plant), it treats it as a standard Labour entry.
Validation vs. Creation:
When you click Submit, the script purely runs a "Test." It builds the log in the background to see if it would be valid. If data is missing (like an Attachment duration), it stops you here.
When you click Approve, the script actually creates the Rental Log records in the system.
Attachments:
You can add up to 5 attachments (like buckets, augers, or breakers). The script checks that each attachment exists in the Plant module and has a duration greater than zero.
Common Blockers
The "Ghost" Operator: If you select a machine (Plant) but do not select a valid Employee field, the script will block submission.
Invalid Times: You cannot have an End Time that is earlier than the Start Time (unless it crosses midnight successfully).
Payroll Timesheet Scripts
Scripts: GenericPayrollTimesheetValidate & GenericPayrollTimesheetCreate
What do these scripts do?
These are the strictest scripts. They calculate total payable hours, deduct breaks (Lunch and Smoko), and ensure an employee isn't claiming to work two jobs at the exact same time.
How does it work?
The Calculation Engine:
The script takes your Start Time and End Time, then subtracts both the Lunch Duration and Smoko Duration.
Example: 8 hours elapsed - 30 min Lunch - 15 min Smoko = 7.25 Payable Hours.
If you map the Total Duration Field, the script will automatically write this result (7.25) into that field for you.
Overlap Protection:
The script looks at the employee's entire day. If Job A is entered as 08:00–12:00, and Job B is entered as 11:30–14:00, the script will block submission because the times overlap.
Allowance Rules:
If you add Allowances (like "Meal Allowance" or "Travel"), the script checks if they are valid. If the allowance is "By Quantity," you must enter a number greater than zero.
Common Blockers
Negative Duration:
If your Lunch + Smoko breaks are longer than the time between Start and End, the result is zero or negative working hours. The script will reject this.
Missing Pay Type:
Even if the Employee exists, if their profile in the database doesn't have a "Pay Type" configured, the timesheet cannot be processed.
Troubleshooting: Why is my form showing an error?
If you are seeing an error message pop up when trying to submit, check the table below for the likely cause and solution.
Error Type |
What it usually means |
How to fix it |
|---|---|---|
"Invalid [Field] Value" |
The script expects a number or a date, but found text or nothing. |
Check your Duration fields. Ensure "Lunch" is just a number (e.g., |
"Selected [Value] does not exist in Database" |
The item selected in a dropdown (Job, Plant, Cost Code) was likely archived or deleted in the backend. |
Refresh your app/browser to get the latest list. If it persists, contact an Admin to ensure the Code/Job is active. |
"Total Duration does not match..." |
The math doesn't balance. |
(End Time - Start Time - Breaks) must exactly equal (Activity 1 + Activity 2 + Activity 3). Check your math. |
"Invalid Time Range" |
The End time is before the Start time. |
Double-check AM vs PM. |
"Script skipped" |
The script is mapped to an "Enable Script" toggle, and that toggle is off. |
Ensure the hidden or visible flag set to "1" or "true" is actually set. |