Forms, signing and reviews
Forms, Sign and Reviews are separate Foldr features. Each can start a MaSH script at the moment that matters to it. All of them need the MaSH feature, and in all of them the script runs as its owner (see Who a script runs as).
A form reaches a script in three ways.
On submit, as an event. Form Completed is on the Settings > MaSH > Events tab, in the Forms group. A script attached there runs for every submission of every form. The script gets mash.event.form, mash.event.answers and mash.event.submission. When the submitter was anonymous, mash.event.user is empty. Event filters don’t apply to this event.
On submit, chosen by the form. In the form’s settings, add the action Run an automation and choose the script under Automation. The action can carry a condition, a MaSH test on the answers such as answers.amount > 1000. The script runs only when the condition is true. If the same script is also attached to Form Completed, it runs once, not twice. The submission’s activity trail records whether the chosen automation ran, was skipped, or failed.
While the form is filled in. A question’s list of choices can come from a script (a lookup against a share, a database or an API). The script returns the options. A script run from a form’s own action reads the live answers as mash.event.answers and the form’s variables as mash.event.vars. A field not yet filled in reads as null, not as an error.
answers = mash.event.answers
if not answers returnend
amount = answers["Amount"] ?? 0if amount > 1000 printline "Large request: {{amount}}"endA form can also call a webhook as an on-submit action. Paste the webhook’s key into Automation webhook key. If you create a new URL for that webhook, Foldr updates the key in your forms.
Signing
Section titled “Signing”Envelope Completed fires when every signer has signed. The script gets mash.event.envelope, mash.event.signers and mash.event.documents. It is a good place to file the signed copy, set a field, or tell someone. Event filters don’t apply.
Reviews
Section titled “Reviews”A review rule can run an automation when a request is approved or rejected. In the review rule’s outcome actions, choose Run an automation and pick the script. The script gets the file and the decision in mash.event.input:
| Key | Holds |
|---|---|
request | the review request’s id |
outcome | approved or rejected |
path, file, share | where the file is |
rule | the rule’s summary |
fields | the field values captured with the request |
requested_by, decided_by | who asked and who decided |
reason | the approver’s justification |
A review that began from a form submission also hands the script that submission’s details, as Form Completed does.
One difference from event scripts matters here. If the script ends in an error, or records any unhandled error along the way, the review action is marked as failed. An event run would only log it. Write a review script with stoponerror = true and a clear fail message so the review shows something useful.