Pass Data Between Actions and Forms
Sep 12, 2025
Overview
This article provides instructions for passing variable values from Actions to Forms and then retrieving the submitted form data back into Actions. It covers both server-side and client-side methods for populating form fields.
Applies To
- Forms
- Actions
Solution
There are two methods to pass data from an Action to a Form.
- Inject Custom Data with Shared Variables (Server-Side)
You can inject server-side variables using thevarsproperty as a second argument in your render method. This can be used to inject sensitive information without exposing it to the client-side.
In this example, the value123populates the variable named:sensitive_variableexports.onExecutePostLogin = async (event, api) => { api.prompt.render(':form_id', { vars: { sensitive_variable: '123', } }); } exports.onContinuePostLogin = async (event, api) => { // Add your logic after completing the form } Populate Values for Existing Fields (Client-Side)
You can populate values for existing fields and hidden fields using thefieldsproperty as a second argument in your render method. Please remember to not populate any sensitive information using this method - populated values are exposed to the browser (client-side).
In this example, the valueMattpopulatesusernamefield.exports.onExecutePostLogin = async (event, api) => { api.prompt.render(':form_id', { fields: { username: 'Matt', } }); } exports.onContinuePostLogin = async (event, api) => { // Add your logic after completing the form }
Related References
See Render Forms using Actions for examples.