Get previous step
Function: Get previous step
This function helps you navigate through a "Stepper" UI element by finding the step that comes right before the one currently displayed. It's useful for creating "Back" buttons or managing multi-step processes in your application.
Input
- Stepper ui element: This is the visual "Stepper" component on your page. You need to select the specific Stepper you want to interact with. This input is required.
Output
- Result: This is where the function will store the unique identifier (code) of the previous step. You can choose a name for this variable, and its default name is "PREVIOUS_STEP". The output will be a number.
Execution Flow
Real-Life Examples
Here are some examples of how you can use the "Get previous step" function:
Example 1: Implementing a "Back" button in a multi-step form
Imagine you have an application form divided into several steps using a Stepper component. You want to allow users to go back to the previous step.
- Inputs:
- Stepper ui element:
MyApplicationFormStepper(the name of your Stepper component)
- Stepper ui element:
- Result: The function will store the numerical code of the step before the current one (e.g.,
1if the current step is2) into a variable namedPREVIOUS_STEP. You can then use this variable to set the Stepper to that specific step.
Example 2: Conditional logic based on previous progress
You might want to perform a specific action only if the user has completed a certain previous step.
- Inputs:
- Stepper ui element:
OnboardingProcessStepper
- Stepper ui element:
- Result: If the user is currently on "Step 3", the function might return
2(the code for "Step 2") and store it inPREVIOUS_STEP. You could then use a condition like "IfPREVIOUS_STEPis2, then show a specific message."
Example 3: Logging user navigation for analytics
You want to track the sequence of steps a user takes in a complex workflow.
- Inputs:
- Stepper ui element:
ComplexWorkflowStepper
- Stepper ui element:
- Result: When a user moves from "Step 5" to "Step 6", and you trigger this function, it will store
5(the code for "Step 5") inPREVIOUS_STEP. You can then log thisPREVIOUS_STEPvalue along with the current step to understand user paths.