Manage backend scripts, event triggers, and scheduled tasks in Timill Platform.
Script Management#
Creating Scripts#
- Navigate to Group Settings → Backend Scripts
- Click New Script
- Choose language: JavaScript or Gonja
- Write script code
- Configure trigger type and schedule
- Save
Script Types#
| Type | Trigger | Use Case |
|---|---|---|
| Manual | Execute on demand | One-time operations |
| Schedule | Cron expression | Daily reports, cleanup tasks |
| Event | Item events | Auto-assign, notifications |
| Save Hook | After item save | Validation, field updates |
Viewing Execution History#
- Go to Group Settings → Backend Scripts
- Click on a script to view its execution history
- Check logs for output and errors
Event Triggers#
Available Events#
| Event | Trigger |
|---|---|
CREATE | Item is created |
UPDATE | Item is updated |
DELETE | Item is deleted |
STATUS_CHANGE | Item status changes |
FIELD_UPDATE | Specific field is updated |
ASSIGN | Item is assigned/unassigned |
COMMENT_CREATE | Comment is added |
Configuring Field Conditions#
For FIELD_UPDATE events, specify which fields trigger the script:
Fields: priority, status, dueDate
The script will only run when one of these fields is modified.
Scheduled Tasks#
Cron Expression Format#
┌───────────── second (optional)
│ ┌───────────── minute
│ │ ┌───────────── hour
│ │ │ ┌───────────── day of month
│ │ │ │ ┌───────────── month
│ │ │ │ │ ┌───────────── day of week
│ │ │ │ │ │
* * * * * *
Common Examples#
| Schedule | Cron Expression | Description |
|---|---|---|
| Every hour | 0 * * * * | Run at the start of each hour |
| Daily at 9 AM | 0 9 * * * | Run daily at 9 AM |
| Weekly on Monday | 0 9 * * 1 | Run every Monday at 9 AM |
| Monthly on 1st | 0 9 1 * * | Run on the 1st of each month |
| Every 5 minutes | */5 * * * * | Run every 5 minutes |
Security Considerations#
Script Permissions#
- Scripts run with the permissions of the script owner
- Group admins can create/modify scripts in their groups
- Instance admins can manage scripts across all groups
Secrets Management#
Scripts can access encrypted secrets via secrets.get():
- Navigate to Group Settings → Secrets
- Add secret keys and values
- Access in scripts:
secrets.get("API_KEY")
API Call Limits#
| Script Type | API Call Limit | Timeout |
|---|---|---|
| Backend Scripts | 100 | 30 seconds |
| Widget Scripts | 50 | 30 seconds |
| Chart Scripts | 50 | 10 seconds |
Monitoring#
Execution Logs#
View script execution logs:
- Group Settings → Backend Scripts → [Script] → Execution History
- Check for errors or unexpected output
- Monitor execution times
Performance Tips#
- Keep scripts small and focused
- Use specific queries to minimize data transfer
- Schedule heavy tasks during off-peak hours
- Monitor API call usage
Troubleshooting#
Script Not Running#
- Verify trigger configuration
- Check script syntax for errors
- Review execution logs
- Ensure user has permission to execute scripts
Timeout Errors#
Scripts timeout after configured duration. Reduce query complexity or split into multiple scripts.
API Call Limit Exceeded#
Review script to reduce API calls:
- Use specific queries instead of broad ones
- Cache results when possible
- Batch operations together
See also:
- Scripting Overview — All scripting environments
- API Reference — Complete API docs
- Backend Scripts — Script creation guide