This article describes how to open the Edit form on the same tab that the user has selected on the Display form.
When your Display and Edit forms use a tab control with the same tabs, users expect to stay where they are when they switch to editing. By default, the Edit form always opens on its first (default) tab, so a user who was reading the History tab has to find it again.
With the [[@Tabs.TabControl1.SelectedTabInternalName]] expression placeholder and the Redirect to tab action, you can pass the selected tab from the Display form to the Edit form. This keeps the user's context and does not change the Edit form's behavior when it is opened from a list view.
Table of Contents
Scenario
- You have a list whose Display form and Edit form both contain a tab control with the same tabs, for example Details and History.
- The Display form has a button that opens the Edit form in a panel.
- You now want to:
- Open the Edit form on the tab the user has selected on the Display form.
- Keep the Edit form's default tab when it is opened from the list view.
Prerequisites
- The tab control exists on both forms. In this article it is named TabControl1.
- Each tab has an internal name, and the internal names are identical on both forms (for example Details and History).
- The Edit form is opened in a panel from the Display form.
IMPORTANT: The comparison uses the tab's internal name, not its display title. If the internal names differ between the two forms, the Edit form cannot match the selected tab.
Step-by-Step Configuration
Step 1: Save the selected tab on the Display form
On the Display form, open the actions of the button that opens the Edit form.
- Add an Execute script action with the following script:
-
window.sbSelectedTab = [[@Tabs.TabControl1.SelectedTabInternalName]]; - Replace TabControl1 with the name of your tab control. You can find the name in the Expressions configuration panel of the tab control, in brackets after Tabs, for example Tabs (TabControl1).
The [[@Tabs.TabControl1.SelectedTabInternalName]] placeholder returns the internal name of the tab that is currently selected, for example History.
Step 2: Open the Edit form
In the same button, add the action that opens the Edit form.
- Add an Open list form action.
- Select the Edit form and set it to open in a panel.
IMPORTANT: The Execute script action from Step 1 must run before the Open list form action. Otherwise the variable is empty when the Edit form loads.
Step 3: Redirect to the matching tab on the Edit form
On the Edit form, open the after-load actions and add one Redirect to tab action for each tab.
- Redirect to tab Details
-
Condition:
=window.sbSelectedTab == "Details" - Redirect to tab History
-
Condition:
=window.sbSelectedTab == "History"
Only the action whose condition matches the saved tab runs. If none matches, the Edit form stays on its default tab.
Step 4: Clear the variable
Still in the after-load actions of the Edit form, add a final action after all Redirect to tab actions.
- Add an Execute script action with the following script:
-
window.sbSelectedTab = null;
IMPORTANT: Without this step, the variable keeps its last value. The next time the Edit form opens, for example from the list view, it would jump to that old tab instead of its default tab.
Additional Hints and Special Cases
More than two tabs
Add one Redirect to tab action per tab on the Edit form, each with its own condition. Keep the Execute script action that clears the variable as the last action.
Tabs that only exist on the Display form
If the user selects a tab that does not exist on the Edit form, no condition matches and the Edit form opens on its default tab. No extra configuration is needed.
Opening the Edit form outside a panel
The window.sbSelectedTab variable only lives in the current browser page. If the Edit form opens as a new page instead of a panel, the variable is lost and the Edit form opens on its default tab.