Formulayt can trigger logic through rules, scripts added to Events in the platform, and JavaScript added to the page using the client-side API. The order in which they fire depends on what triggers the logic and how the form is submitted.
Before submission
When a user changes a field, Formulayt processes the change in the following order:
Field value changes
↓
"Field changed" Event code triggers
↓
Continuous rules watching the field triggers
Note: Continuous rules on trigger when the condition they are watching changes. They do not trigger again when the user clicks Submit unless the submission itself changes a field they are watching.
During submission
When a valid form is submitted, the following order applies:
Validation completes
↓
"On submission" rules trigger
↓
gcdcGateSubmit on-page code triggers
↓
The submission method takes control
This means that if you have both an On submission rule and a gcdcGateSubmit listener, the rule triggers first.
When submission logic changes a field
An On submission rule can trigger additional continuous rules if it changes a field that those rules are watching.
On submission rule triggers
↓
Rule changes a watched field
↓
Continuous rules trigger
↓
Remaining On submission rules trigger
↓
gcdcGateSubmit on-page code triggers
The same applies to field changes made by gcdcGateSubmit code.
For example:
field.setValue('New value', true);
The true tells Formulayt to process the change. Any continuous rules watching that field trigger before the gcdcGateSubmit handler finishes and submission continues.
After Submission
The Submission Event fires at a different point depending on the submission method.
Fetch submission
Fetch request resolves successfully
↓
Submission Event
↓
gcdcGateSubmitted
Iframe submission
Submission started
↓
Submission Event
↓
gcdcGateSubmitted
Custom integration
Integration reports success
↓
Submission Event
↓
gcdcGateSubmitted
Synchronous submission
Submission Event
↓
Short delay
↓
Payload sent
↓
Page unload
For synchronous submissions, gcdcGateSubmitted does not fire because the page unloads.
The Submission Event and gcdcGateSubmitted indicate that Formulayt has completed its submission work. They do not guarantee that the destination system has accepted or processed the submitted data.
If submission fails
Different Events trigger depending on where the submission fails.
Validation fails when trying to submit the form
The Validation failed Event triggers.
gcdcGateSubmitdoes not fire.gcdcGateSubmitteddoes not fire.
Validation passes but the form cannot be submitted
gcdcGateSubmithas already been fired.The Submission failed Event triggers.
gcdcGateSubmitteddoes not fire.
Asynchronous JavaScript
Formulayt waits for normal synchronous JavaScript inside gcdcGateSubmit, but it does not wait for asynchronous operations such as fetch().
If a field needs to be changed before the submission takes place, make that change synchronously inside the gcdcGateSubmit handler.
