Activating HMI Screens by Tag in WinCC Flexible 2008 and TIA Portal V20 Unified
Dynamic screen activation by tag value gives an HMI application a single, scalable navigation entry point instead of dozens of hard-wired buttons. In plants with 50, 100, or several hundred screens, fixed navigation buttons become impractical to engineer and maintain. By binding a screen name to a string tag and routing that name through a script, you keep navigation logic in one place and localize it for translation and authorization.
This reference covers three working implementations:
-
WinCC Flexible 2008 / WinCC VBScript — using
HmiRuntime.BaseScreenNameassignment to change the base screen. -
WinCC Flexible ActivateScreen system function — with conditional or
Select Caselogic. - TIA Portal V20 Unified Runtime — screen dynamization via a script trigger bound to a PLC tag.
Each approach trades off compatibility, runtime overhead, and engineering effort. Field engineers retrofitting legacy MP277 10" panels use method 1; new installations on TP1500 / TP2200 Comfort or Unified Comfort Panels use method 3.
Prerequisites
| Item | WinCC Flexible 2008 | TIA Portal V20 Unified |
|---|---|---|
| Engineering software | SIMATIC WinCC flexible 2008 SP5 or later | TIA Portal V20 (or V18/V19 back-ports) |
| Runtime target | MP277 10" Touch (Windows CE 5.0) | Unified Comfort Panel, WinCC Unified PC Runtime |
| Minimum license | WinCC flexible RT 128 / 256 / 512 / 2048 PowerTags | WinCC Unified Comfort (TIA Portal) — minimum 100 PowerTags |
| Scripting language | VBScript (subset) | JavaScript (Unified scripting API) |
| Reference manual | Siemens FAQ 25011172 — Dynamic Screen Selection | TIA Portal V20 — Triggering a Screen Change with a Tag |
Method 1 — WinCC Flexible 2008: HmiRuntime.BaseScreenName Assignment
This is the canonical solution for legacy MP277 panels. The script runs on a button Press event and reassigns the base screen property to the value of a string tag bound to an IO field.
Tag Configuration
| Property | Value |
|---|---|
| Tag name | ScreenTag |
| Data type |
String (UTF-8 / ASCII) |
| Length | 30 characters (sufficient for any screen name) |
| Acquisition cycle | 1 s, or "On demand" for event-driven update |
| PLC connection | Internal (HMI-local) or external (from PLC DB) |
| Update on tag change | Enabled (required for tag-event triggered scripts) |
| Initial value |
"" or the startup screen name |
Step-by-Step Procedure
- Open the project in WinCC flexible 2008.
- Create the internal tag
ScreenTagof typeString, length 30. - Place an IO field on the "Navigation" screen. Configure: process tag
ScreenTag, modeInput / Output, formatString, length 30. - Place a "Go" button below the IO field.
- Configure the button event
Press→CallScript. - Enter the script body:
' WinCC flexible 2008 — Activate screen by tag value ' Trigger: Button "Go" — Press event ' Tag: ScreenTag (String, 30 chars) Dim sScreenName sScreenName = SmartTags("ScreenTag") ' Validate input — reject empty or oversized values If Len(sScreenName) = 0 Then ShowSystemAlarm "Screen name is empty. Enter a valid screen name." Exit Sub End If If Len(sScreenName) > 30 Then ShowSystemAlarm "Screen name exceeds 30 characters." Exit Sub End If ' Guard against recursion: skip if already on target screen If HmiRuntime.BaseScreenName = sScreenName Then Exit Sub End If ' Optional: log navigation event to alarm buffer SmartTags("LastScreenTag") = sScreenName ' Activate the screen — primary method HmiRuntime.BaseScreenName = sScreenName - Compile the project (
Project → Compiler → All). - Transfer the runtime to the MP277 using Ethernet (RFC 1006) or USB-PPI.
- Reboot the panel to load the new runtime.
Verification
- Type
Screen_Overviewin the IO field and press the button. The base screen should swap within ~200 ms. - Type a non-existent name (e.g.,
DoesNotExist). The runtime logs an error in the diagnostic buffer and remains on the current screen. - Inspect the HMI diagnostic buffer via
Start → Settings → OP → Diagnosticsor remote via ProSave. - Confirm
LastScreenTagtag in the tag simulator reflects the last successful navigation.
Method 2 — WinCC Flexible: ActivateScreen System Function
For projects that cannot use VBScript (older panels, RT-only licenses) use the built-in ActivateScreen system function. Note that ActivateScreen requires a string literal, not a variable — so a direct call like ActivateScreen ScreenChoiceTag, 0 raises a syntax error. The recommended indirection is:
' ActivateScreen with parameter derived from string tag
' Note: ActivateScreen takes a screen NAME literal, not a variable
' So we use indirect assignment via HmiRuntime
Dim sTarget
sTarget = SmartTags("ScreenTag")
' ActivateScreen cannot accept variables directly, so we route through BaseScreenName
HmiRuntime.BaseScreenName = sTarget
If the application genuinely requires the ActivateScreen function (for example, to trigger pop-up screens with field-specific parameters), use a Select Case ladder:
Select Case SmartTags("ScreenTag")
Case "Overview" : ActivateScreen "Screen_Overview", 0
Case "Diagnostics" : ActivateScreen "Screen_Diagnostics", 0
Case "Alarms" : ActivateScreen "Screen_Alarms", 0
Case "Trends_Temp" : ActivateScreen "Screen_Trends_Temp", 0
' … 64 more cases …
Case Else : ShowSystemAlarm "Unknown screen: " & SmartTags("ScreenTag")
End Select
Scale-Out Variant: Textlist Selection
For 68+ screens, replace the IO field with a Textlist. Textlists in WinCC flexible 2008 support tag-driven entry selection at runtime, removing free-text input entirely and providing automatic localization through the runtime language.
| Text (Display) | Value (Tag) |
|---|---|
| Overview | Screen_Overview |
| Diagnostics | Screen_Diagnostics |
| Alarms | Screen_Alarms |
| Trends (Temperature) | Screen_Trends_Temp |
| Trends (Pressure) | Screen_Trends_Pressure |
Bind the Textlist output to ScreenTag. The user selects a row from a drop-down; pressing the button activates the corresponding screen. The displayed text changes with the HMI runtime language, while the underlying string tag stays constant.
Method 3 — TIA Portal V20 Unified Runtime
The Unified Runtime replaces WinCC flexible's VBScript with a JavaScript-based scripting API. Screen dynamization via tag triggers is configured per-screen in the screen editor. This is the recommended path for all new projects.
Step-by-Step Procedure
- Open the project in TIA Portal V20.
- Create a PLC tag
PLC_State_Tag(String[30]) or an internal HMI tag with equivalent definition. - Open the target screen in the screen editor.
- Select a UI element (e.g., the screen background or a hidden rectangle).
- Open the Dynamization column in the properties pane.
- Add a new dynamization → type
Script. - Configure the trigger tag: select
PLC_State_Tag(or the equivalent HMI tag). - Insert the script body:
// TIA Portal V20 Unified — screen dynamization script // Trigger: PLC_State_Tag value change // Reference: docs.tia.siemens.cloud/r/en-us/v20/runtime-scripting-rt-unified let sScreenName = Tags("PLC_State_Tag").Read(); if (sScreenName === undefined || sScreenName.length === 0) { HMIRuntime.Trace("Screen activation aborted: empty tag value"); return; } let targetScreen = sScreenName.trim(); // Guard against recursion if (HMIRuntime.Screens.BaseScreen === targetScreen) { return; } try { Screen.Items(targetScreen); // existence check HMIRuntime.Screens.BaseScreen = targetScreen; HMIRuntime.Trace("Activated screen: " + targetScreen); } catch (e) { HMIRuntime.Trace("Failed to activate screen '" + targetScreen + "': " + e.message); } - Compile the project.
- Download to the Unified Comfort Panel or start the PC Runtime simulation.
Verification
- Change
PLC_State_Tagfrom the PLC (e.g., via a watch table) and observe the panel. - Inspect the runtime trace:
Start → Runtime → Trace Vieweror via theHMIRuntime.TraceAPI. - Confirm no "Screen not found" errors in the diagnostic buffer.
- Verify the
Screen.Items(name)call raises an exception (caught by try/catch) when the screen does not exist.
Feature Comparison
| Feature | WinCC Flexible (BaseScreenName) | WinCC Flexible (ActivateScreen ladder) | TIA Portal V20 Unified |
|---|---|---|---|
| Code length | 1 line | 68+ cases | ~15 lines |
| Maintenance | Single point of change | Per-case maintenance | Single script per screen |
| String tag as parameter | Yes (indirect via BaseScreenName) | No (literal only) | Yes (full scripting API) |
| Validation/error handling | Manual (VBScript) | None (system handles) | Manual (try/catch) |
| Localization-friendly | With Textlist | No | With text lists |
| Runtime CPU impact | Negligible (one assignment) | Negligible | Low (script evaluation per change) |
| Compatibility | MP 277, MP 377, Comfort Panels (with migration) | All WinCC flexible targets | Unified Comfort Panel, Unified PC RT V18+ |
| License cost | Included in RT | Included in RT | Requires WinCC Unified license |
| Tag-event trigger | Yes (OnChange) | Yes (OnChange) | Yes (Dynamization trigger) |
Configuration Reference
System Functions — WinCC Flexible 2008
| Function | Purpose | Returns |
|---|---|---|
ActivateScreen ScreenName, FieldNumber |
Change to a named screen with optional field focus | Boolean (success) |
HmiRuntime.BaseScreenName |
Get/set the current base screen name | String |
HmiRuntime.CurrentScreenName |
Get the current screen (read-only) | String |
HmiRuntime.Screens(screenName).ScreenItems(itemName) |
Access a screen item by name | Object |
SmartTags("TagName") |
Read/write a tag value | Variant |
ShowSystemAlarm "text" |
Display a system alarm | None |
Unified Runtime API — TIA Portal V20
| Function | Purpose | Reference |
|---|---|---|
Tags("TagName").Read() |
Read a tag value | TIA Portal V20 Runtime Scripting |
Tags("TagName").Write(value) |
Write a tag value | Same |
HMIRuntime.Screens.BaseScreen |
Set/get the base screen | Same |
Screen.Items(name) |
Check screen existence | Same |
HMIRuntime.Trace(text) |
Write to the trace viewer | Same |
HMIRuntime.Authorization.Check(level) |
Verify operator authorization | Same |
Tag-Event Triggered Scripts
In addition to button triggers, both WinCC flexible and TIA Portal Unified support scripts that fire automatically when a tag value changes. This eliminates the "Go" button entirely — any PLC write to ScreenTag triggers the navigation.
WinCC Flexible 2008 Configuration
- Right-click the tag
ScreenTag→ Properties → Events. - Select
OnChange. - Attach a script that performs the same
HmiRuntime.BaseScreenName = SmartTags("ScreenTag")assignment. - Set the tag acquisition cycle to "On demand" or
100 msif the change originates from the PLC. - Add a debounce check using an internal
LastValueTagto skip repeated equal writes.
TIA Portal V20 Unified Configuration
- Open the screen editor → select an item → Properties → Dynamization.
- Add a script trigger and select the tag.
- Reference the official TIA Portal V20 example for syntax.
- Set the trigger quality filter to "Good" only — ignore stale or uncertain values.
Commissioning Checklist
- Compile the project with zero errors and zero warnings.
- Transfer the runtime to the panel and confirm version timestamp.
- Verify all tags are present:
Start → Settings → OP → Tags(WinCC flexible) orOnline → Tags(Unified). - Manually navigate to each screen via the IO field / Textlist and confirm.
- Force the PLC tag to invalid values via the watch table and confirm graceful failure.
- Toggle operator authorization down and confirm the navigation script is blocked.
- Capture diagnostic buffer or trace output for at least one full navigation cycle.
- Verify alarm/event logging captures every navigation if 21 CFR Part 11 / GMP audit trail applies.
- Stress-test: write the tag 10 times per second for 60 seconds and confirm no screen flicker or runtime crash.
- Sign off the FAT/SAT with the diagnostic buffer snapshot attached.
Troubleshooting Matrix
| Symptom | Likely Cause | Fix |
|---|---|---|
ActivateScreen ScreenChoiceTag, 0 errors with "Type mismatch" |
ActivateScreen expects a string literal, not a variable | Use HmiRuntime.BaseScreenName = SmartTags("ScreenChoiceTag")
|
| Script runs but screen does not change | Screen name typo or case mismatch | Verify exact spelling in screen properties; WinCC flexible is case-sensitive in some builds |
| Runtime freezes after several navigations | Screen change triggers tag-event recursion | Add guard: If HmiRuntime.BaseScreenName = sScreenName Then Exit Sub
|
| Screen change works in simulation but not on panel | Tag not transferred to panel | Re-transfer runtime; verify tag in OP → Tags view |
| "Permission denied" writing BaseScreenName | Operator authorization level too low | Set authorization to "Operator" or higher on the script trigger |
| Empty tag value causes runtime error | Uninitialized string tag | Initialize tag in PLC startup OB or HMI startup script |
| Textlist shows raw tag value instead of friendly text | Textlist misconfigured | Configure Textlist with "Value/Text" pairs and bind output to the correct tag |
| TIA Portal V20 script throws "Screen not found" | String has trailing whitespace or special characters | Trim the value and validate against a known screen list |
| Multiple rapid tag changes cause screen flicker | Debouncing missing | Add a delay or only act on rising edge (old value ≠ new value) |
| Tag value updates in PLC but HMI does not see it | Acquisition cycle too slow or wrong connection | Reduce cycle to 100 ms and confirm connection in Connections editor |
| Script executes in simulator but no screen change on panel | PowerTag license exceeded | Check license diagnostics; consolidate or upgrade license |
| Diagnostic buffer shows Event ID 13001 | Screen change target invalid | Inspect the trace output for the failed target name |
Performance & Safety Considerations
-
Debounce rapid writes. A PLC writing
ScreenTagin a 100 ms loop floods the script trigger. Use a 1-second debounce timer or only fire on value change (not every scan). - Validate input. Free-text IO fields accept any string; a corrupted PLC value can navigate to unintended screens. Always validate against a known screen list before assignment.
-
Authorization. Tie the navigation script to an operator authorization level to prevent unauthorized screen access. In WinCC flexible, set the event's "Authorization" property; in Unified, wrap the script in
HMIRuntime.Authorization.Check(). -
Logging. Use
ShowSystemAlarmorHMIRuntime.Traceto log every screen change with timestamp and operator ID for audit trail compliance (FDA 21 CFR Part 11, GMP, ISA-95). - License boundaries. Each tag used in a script counts toward the PowerTag license. WinCC flexible 2008 panels ship with 128 / 256 / 512 / 2048 PowerTags depending on the license. A project with 68 screens and 3 navigation tags stays well under 128 PowerTags, but adding 200 data tags will push toward the next license tier.
-
Migration. Projects migrated from WinCC flexible 2008 to TIA Portal V20 require the VBScript to be re-written in JavaScript. The
HmiRuntime.BaseScreenNameproperty does not exist in Unified; useHMIRuntime.Screens.BaseScreeninstead. -
Tag quality code handling. In Unified, always check
Tags("PLC_State_Tag").Qualitybefore activating — a "Bad" or "Uncertain" quality should not trigger navigation.
Related Documentation
- Siemens FAQ 25011172 — Dynamic Screen Selection in WinCC flexible
- TIA Portal V20 — Triggering a Screen Change with a Tag (Unified)
- Inductive University — Tag Event Scripts Video
Can ActivateScreen in WinCC flexible 2008 accept a string variable directly as a parameter?
No. ActivateScreen expects a string literal (a screen name in quotes). To pass a variable, assign HmiRuntime.BaseScreenName = SmartTags("ScreenTag") or use a Select Case ladder with explicit cases for each screen name.
How do I activate a screen by tag in TIA Portal V20 Unified Runtime?
Open the screen editor, add a script dynamization, set the trigger tag (e.g., PLC_State_Tag), and assign HMIRuntime.Screens.BaseScreen = Tags("PLC_State_Tag").Read() in the script body. See the official TIA Portal V20 example.
What is the maximum number of screens I can navigate to from a single IO field?
The string tag length limits the practical maximum. A 30-character string tag can hold any screen name in standard WinCC flexible / Unified projects. The number of distinct screens is bounded by the runtime license (128 / 256 / 512 / 2048 / unlimited PowerTags) and the panel's flash memory.
How do I trigger screen changes automatically when a PLC tag changes?
In WinCC flexible 2008, attach a script to the tag's OnChange event. In TIA Portal V20 Unified, configure a screen dynamization with a script trigger bound to the PLC tag. The script fires on every value change; add debounce logic or a guard against equal-value writes to prevent flicker.
Why does my screen change script work in simulation but not on the physical MP277 panel?
Common causes: (1) the runtime was not re-transferred after the script was added, (2) the tag length is too short for the actual screen name, (3) operator authorization is too low, (4) the screen name contains characters not supported in the panel's active language, or (5) the PowerTag license has been exceeded. Verify each item against the diagnostic buffer before contacting Siemens support.