Personal toolkit for working with Laserfiche modern Forms inline JavaScript — capture/replay test data, accumulated API quirks, and per-form source backups.
You have a form that you need to test many times. Maybe it triggers a workflow and/or a document merge rule and you're tired of entering test data into the form to make downstream tweaks.
Modern Laserfiche Forms have no built-in way to save test data. Filling out a 30-field form by hand every time you tweak a script is painful. This repo provides:
- Capture/inject snippets to record current form values as JSON and replay them on page load
- API quirks documentation — the not-obvious sandbox behaviors that took real time to figure out
- Per-form source backups — version-controlled copies of each form's inline JS
- Paste
capture-via-field.jsat the bottom of your form's inline JS. - If your form already has an
onFormSubmissionhandler, comment it out temporarily. - Save the form. Open it, fill out fields with your desired test values.
- Click Submit. Submission is blocked, and the bridge field on the page now contains pretty-printed JSON of every other field's value.
- Copy that JSON out of the bridge field. Save it to
forms/<form-name>/test-data.jsonfor safekeeping. - Remove the capture snippet from inline JS, restore the original
onFormSubmission.
Go here for the full instructions: Integration guide
-
Capture test data from a manually-filled form:
- Paste
snippets/capture.jsat the bottom of your form's inline JS - Save, fill out the form, click Submit
- Copy the JSON from the browser console
- Save to
forms/<form-name>/test-data.json
- Paste
-
Inject on reload:
- Paste
snippets/inject.jsat the bottom of your inline JS - Replace the
TEST_DATAplaceholder with your captured JSON - Reload the form — fields auto-populate
- Paste
-
Toggle off for production by flipping
INJECT_TEST_DATA = false.
laserfiche-form-tools/
├── snippets/ Reusable capture/inject templates
├── docs/ API quirks, integration guide
└── forms/ Per-form: inline.js, test-data.json, notes.md
- Integration guide — how to add snippets to existing inline JS
- API quirks — sandbox behaviors and gotchas
- Laserfiche modern Forms (sandboxed JS environment)
- No jQuery, no direct DOM manipulation, no
alert() - All work flows through the
LFForm.*API