Form Architecture
Forms consist of five closely related parts:- Form: Container with metadata and settings (including workflow overrides)
- FormElement: Individual fields and UI components within the form
- FormSite: Deployment link connecting a form to a specific site and year
- FormSubmission: Submission container for a form at a site/year
- FormElementSubmission: Individual field values inside a submission
Form Settings
Every form stores behavioral controls inside asettings object that is validated by updateForm. Fields are optional—if you omit one, the form falls back to the organization default or the existing persisted value.
Public submission options
allowPublicSubmissionEdits: Whentrue, public contributors can reopen an existing submission (or draft) and change their answers without staff intervention. When omitted, the platform’s default editing policy is applied.allowPublicSubmissionSupportingDocuments: Enables the supporting-document drawer for unauthenticated contributors so they can upload evidence while filling out public forms. Leaving it undefined preserves the default document policy.publicSupportingDocumentsMode: Controls how broadly attachments are allowed onceallowPublicSubmissionSupportingDocumentsis turned on. Accepted values:all(default): Every element that supports attachments exposes the public drawer.opt-in: Only elements with metadataallowSupportingDocumentsUpload: truewill expose the drawer. Admins toggle this per element in the builder next to the Required switch.
Workflow override
workflowOverride is an optional object with a single type key. Accepted values are DIRECT_APPROVAL and REQUIRE_APPROVAL, matching the workflow states described below. Supplying null or omitting the object makes the form inherit the organization-level workflow rules.
Scheduling and reminders
Use the optionalschedules object to force due dates and reminder behavior for either phase of the process:
dataEntry: Controls contributor deadlines.approval: Controls reviewer deadlines.
period: Currently must be the literal"MONTHLY". Other cadences will be added later, so the schema pins the value withz.literal("MONTHLY").dueDay: Integer day of month between 1 and 28 (UTC).reminders: Optional{ enabled: boolean; offsets: number[] }block. Offsets represent how many days beforedueDayto send a reminder and must be drawn from{1, 3, 7}. Invalid entries are rejected by the schema. Reminders can also be omitted entirely, which disables notifications while keeping the due day.
parseFormSettings and getReminderConfig (see apps/azalt/src/server/api/routers/form/methods.ts) to coerce stored JSON and to discard malformed dueDay or offset values before running scheduled jobs.
Form Types & Deployment
Internal forms (private)- One submission per FormSite (site + year) is enforced while not deleted
- Team members enter data directly in the platform
- CSV bulk import/export and API integration for automation
- Auto-save UX depending on the view (create/update on change)
- Public endpoints per FormSite (no authentication)
- Multiple submissions per site/year are allowed
- Optional review via per-field approvals (see Workflow)
- Optional branded header via form metadata (logo, colors)
Smart Form Features
Conditional logic: Dynamic behavior based on other elements- YEARLY: One period unit (1)
- MONTHLY: 12 period units (1–12)
- QUARTERLY: 4 period units (1–4)
- TIMESTAMP: Point-in-time entries with a
recordedAtUTC timestamp (periodUnit derived from recorded month)
- total: Values represent totals that roll up over time (e.g., emissions)
- snapshot: Point-in-time values that should not be distributed (e.g., factors)
Advanced Form Builder
Visual editor: Drag-and-drop interface for form construction- Real-time preview
- Element reordering and nesting
- Copy/paste elements across forms
- Create from CSV or duplicate existing forms
- CSV import (bulk)
- Duplicate & customize
- Manual builder
- Drag-and-drop condition creation
- Multiple condition types (equals, contains, greater than, etc.)
- Nested condition groups with AND/OR logic
- Real-time validation and preview
Data Collection Workflow
1. Form Design: Build form structure with elements and logic 2. Deployment: Assign to specific sites and years- Direct platform entry
- CSV import with validation
- API integration
- Public form submissions (if enabled)
- Required field enforcement
- Type/format validation
- Conditional logic
- Unit compatibility checks
- CSV/XLSX export
- API endpoints
- Dashboard integration
- Summary statistics
Workflow and Approvals
Forms inherit the organization’s default workflow and can optionally override it per form via settings:- DIRECT_APPROVAL: New values are saved as APPROVED
- REQUIRE_APPROVAL: New values are saved as COMPLETED and require approval
REQUIRE_APPROVAL mode, the submission interface exposes:
- Inline approval controls: Each period row shows Approve, Reject, and Revert buttons with live status badges. Values that are rejected automatically revert to COMPLETED once edited again.
- Bulk actions: For monthly or quarterly NUMBER/SINGLE_CHOICE/MULTIPLE_CHOICE/LONG_TEXT/SHORT_TEXT elements, approvers can approve or reject every populated period in one click. ACTIVITY elements continue to support bulk approvals for all rows within the same period.
- Status persistence: Status changes update immediately in the UI (no refresh required) and are reflected in downstream reporting.
DIRECT_APPROVAL, approval buttons are hidden and newly saved data is marked as APPROVED automatically.
Supporting Documents
Each element row can open a supporting-document drawer:- Private submissions: Files are attached directly to the underlying FormElementSubmission. Users can upload new evidence, download existing files, and (with permission) delete attachments.
- Public submissions: Opening the drawer creates (or reuses) a draft submission so public contributors can upload files without logging in. The drawer lists previously uploaded documents and exposes download links; deletes are limited to authenticated staff.
- Counters and indicators: Attachment buttons show a badge with the number of linked files, and upload/delete operations refresh immediately.
Developer Mode
Submission pages expose a Copy cURL control when developer mode is enabled. The action copies a ready-to-runcurl command that mirrors the current element identifier, site, year, period unit, and latest value. Teams use this to bootstrap API integrations quickly or to test REST submissions without manually crafting payloads.
Task Progress Tracking
While users enter data, the renderer emits optimistic task-progress metrics:- Data entry progress: Counts remaining vs. total period/element combinations up to the current month, highlighting overdue months based on schedule due days.
- Approval progress: When approvals are required, approvers see remaining vs. total items awaiting review, plus overdue counts.
Public Form Settings
For public forms, additional settings exist on the form:allowPublicSubmissionEditsallowPublicSubmissionSupportingDocuments
Constraints and Notes
- FormElement keys are unique within a form
- ACTIVITY elements cannot use the TIMESTAMP period
- Private forms enforce one active FormSubmission per FormSite (non-deleted)
Real-World Examples
Energy Tracking Form:- Monthly electricity consumption (NUMBER with kWh unit)
- Energy source selection (SINGLE_CHOICE: Grid/Solar/Wind)
- Conditional renewable details (shown only if renewable selected)
- Supporting documentation upload (FILE_UPLOAD)
- Quarterly waste streams (GROUP with multiple NUMBER fields)
- Waste treatment method (MULTIPLE_CHOICE)
- Diversion rate calculation (ACTIVITY with custom formula)
- Site-specific disposal procedures (LONG_TEXT)
- Company information (SHORT_TEXT fields)
- Scope 1, 2, 3 emissions (NUMBER with tCO2e units)
- Activity-based calculations (ACTIVITY for complex emissions)
- Monthly data collection (MONTHLY period setting)
Operational Benefits
- Consistency: Same form structure across all sites and time periods
- Efficiency: Auto-save, bulk operations, and template reuse
- Compliance: Built-in validation and audit trails
- Scalability: Handle hundreds of sites and thousands of submissions
- Flexibility: Adapt forms without losing historical data

