Initialize Form And Stop Execution
Audience:
Low-code EngineersSkill Prerequisites:
Actions,Forms,Tokens
Loads a Form module on the current page, in place, then stops. No further actions run. It's available in forms and listings.
The page isn't refreshed. The form is loaded from the server again, so its fields start over with their initial values and its On Preinit and On Init actions run again. A common setup is to set the form's Display Mode to Manual, so it doesn't load with the page and this action loads it when it's needed. See Display Mode.
| Action | What happens after the form is initialized |
|---|---|
| Initialize Form And Stop Execution | No further actions run. |
| Initialize Form And Continue Execution | The form is loaded right away and the next actions keep running. |
Typical Use Cases
- Load a form that's hidden when the page opens, only when the user needs it, so the page loads faster
- Reset a form after it's been submitted, so the user can enter another record
- Reload a form with different values, such as the record picked in another form or a listing row
Don't use it to
- Run more actions after the form loads. Use Initialize Form And Continue Execution instead.
- Open a form in a popup. Use Open Form Popup And Stop Execution instead.
- Load a form that's on another page. Use Redirect To Url instead.
- Refresh a listing. Use Refresh Listing instead.
Related Actions
| Action Name | Description |
|---|---|
| Initialize Form And Continue Execution | Loads the same form and keeps running the next actions. |
| Open Form Popup And Stop Execution | Opens a form in a popup and ends execution. |
| Open Form Popup And Continue Execution | Opens a form in a popup and keeps running the next actions. |
| Execute Javascript Code And Stop Execution | Runs your own JavaScript in the browser, for example to call dnnsf.api.actionForm.initForm yourself. |
| Stop Execution | Stops running actions without loading anything. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| Select Module | The Form module to initialize. The list shows the Form modules on the site, as Title (#ModuleId). Click EXPR to enter a module ID, such as 1234, or a token that holds one. The module's unique ID (a GUID) also works. The action fails if it's empty or doesn't match a module. | Yes | empty string | Yes |
| QueryString Parameters | Name and value pairs sent to the form when it loads. The form reads them as [QueryString:Name] tokens in its On Preinit and On Init actions. Tokens in both the names and the values are replaced before they're sent. If a name is used twice, the last one wins. | Yes | empty | No |
How the form is initialized
- It runs in the browser. The action sends a small script to the browser. The script calls
dnnsf.api.actionForm.initForm(moduleId, parameters), which asks the server for the form and puts it in place of the old one. - The form starts over. Anything the user typed in it is lost. Fields get their initial values, and
On PreinitandOn Initrun again.On Page Loaddoesn't run again. - Passing values. The form gets the query string of the current page plus the QueryString Parameters. If a name is already in the page's query string, the action's value wins.
Considerations
- The form must be on the page. The list offers every Form module on the site. If the chosen form isn't on the current page, nothing loads and the browser console shows an error.
- Final action. Actions placed after it in the same list never run, unless its condition is false. Use the action's
Conditionto decide when to run it, for example"[Status]" == "Saved". See Common Parameters. - Don't initialize a form from its own
On Init. Initializing the form runsOn Initagain, which would initialize it again. - Not in
On Page Load. Those actions run while the page is being built, before there's a form to load. The action has no effect there. - Not in APIs or workflows. The action runs JavaScript in the browser, so it's only available in forms and listings.
- Same as the JavaScript API. In your own code,
dnnsf.api.actionForm.initForm(1234)does the same, anddnnsf.api.actionForm.initForm(1234, { OrderId: 5 })also passes values.
In Listings
Listings also have Initialize Form, a client-side version of this action. It's only available on buttons with Client Button turned on. It runs in the browser as soon as the button is clicked, without a request to the server.
It has the same parameters as this action. The differences:
- Tokens are replaced when the listing loads, not when the button is clicked. On an item button, that's when the row is shown, so the row's values, such as
[Id], are available. On a root button, only values that don't depend on a row are. - The condition is checked when the listing loads too.
- There's no Stop or Continue. A client button only runs client-side actions, one after another.
Examples
To understand how to use the below examples, please see Running Examples.
1. Load an order form for a listing row
Add this action to an item button in a listing. It loads Form module 1234 on the same page and passes the row's OrderId. In the form's On Init actions, [QueryString:OrderId] holds the ID.
{
"Title": "Initialize Form And Stop Execution",
"ActionType": "InitActionForm",
"Description": "Load the order form for this row",
"Parameters": {
"ModuleId": "1234",
"Params": [
{
"name": "OrderId",
"value": "[OrderId]"
}
]
}
}
2. Reset a form after it's saved
Add this action at the end of a form's submit button. When the Saved token is true, it loads the same form again, empty, so the user can enter the next record. Replace 1234 with the form's own module ID.
{
"Title": "Initialize Form And Stop Execution",
"ActionType": "InitActionForm",
"Description": "Start a new entry after saving",
"Condition": "\"[Saved]\" == \"true\"",
"Parameters": {
"ModuleId": "1234",
"Params": [
{
"name": "Mode",
"value": "New"
}
]
}
}
Revised 09/27/2026