However, when I reference the hidden field named update_profile, the form seems to break. Am I doing this incorrectly? Any additional information on how to pass variables from an Action to a Form would be greatly appreciated.
I have tested this on my end and was able to get it to work successfully without issues.
The first thing you might want to include in your Post Login action script is the onContinuePostLogin function, which allows the form to resume the authentication flow.
exports.onExecutePostLogin = async (event, api) => {
api.prompt.render('ap_1REWW3UztkwjxdGPbqsCya', {
fields: {
update_profile: "true",
}
});
}
exports.onContinuePostLogin = async (event, api) => {
// (Optional) Add your logic after completing the form
}
Next, if your form seems to break, please ensure that your router connects a path for all conditions, including the default case. See the example below:
Thank you for taking the time to replicate this flow on your end. I still seem to be having the same issue where the value doesn’t change the flow when the router is defined?
Here are some more screenshots which should outline everything I’m doing. Basically I just want to have the variable update_profile be passed from the Action to the form flow:
Do I need to add anything else for this logic to work? The code as is always goes into the default case when I want to determine the flow within the Action via the update_profile.
I have identified the issue. Essentially, your Post Login action script does not reference the correct ID. It should reference the ID you defined in your Step settings, ’ test_input_id`.
So, in your Post-Login action script, it should be:
exports.onExecutePostLogin = async (event, api) => {
var app_id = "YOUR_APP_ID"
api.prompt.render(app_id, {
fields: {
update_profile: "true"
test_input_id: "Any text you want here"
}
});
};
When done this way, it will populate the fields correctly.
The step I included was just to test the flow of the form itself. What I was trying to accomplish was to route the user using the Router based on a value (update_profile) which should be set in the action itself. I.e. if the value of update_profile is true (passed from the Action), I want the user to update their profile. If it’s false (default case) I want to just sign them in. Is that possible?
Hopefully that makes sense. I’m trying to use the value passed from the Action to do the initial Router logic before the user is taken to any form.