WinCC VBScript screen navigation, faceplates and reusable instances
Learn how to open contextual detail views, pass approved equipment identity and reuse one screen design across several motors, pumps or valves.
1. Define the navigation architecture before scripting
Start with a screen map showing overview pictures, area displays, equipment details, modal dialogs and the path back to a known location. A script should implement this model rather than inventing navigation independently inside every button.
- Use consistent Home, Back, Area and Close behavior.
- Keep the current equipment identity visible in every detail view.
- Avoid opening multiple uncontrolled copies of the same popup.
2. Choose between a full picture, picture window and popup
| Display type | Suitable use | Design caution |
|---|---|---|
| Full picture | Area or process navigation | Preserve orientation and return path |
| Picture window | Embedded equipment detail | Manage instance context explicitly |
| Popup or dialog | Focused diagnostics or parameter entry | Control modality, position and duplicate instances |
| Faceplate | Standardized equipment operation | Define a stable interface and version |
3. Pass equipment context through an approved identifier
Instead of concatenating arbitrary operator input into tag names, map a known equipment identifier to an approved tag prefix.
Function ResolveMotorPrefix(ByVal equipmentId)
Select Case CStr(equipmentId)
Case "M101": ResolveMotorPrefix = "Plant1_M101"
Case "M102": ResolveMotorPrefix = "Plant1_M102"
Case "M103": ResolveMotorPrefix = "Plant1_M103"
Case Else: ResolveMotorPrefix = ""
End Select
End FunctionAn allowlist prevents malformed names and makes the supported instances visible during review.
4. Prepare a reusable equipment context
Sub SelectEquipment(ByVal equipmentId)
Dim prefix
prefix = ResolveMotorPrefix(equipmentId)
If prefix = "" Then
HMIRuntime.Trace "Unknown equipment: " & CStr(equipmentId) & vbCrLf
Exit Sub
End If
HMIRuntime.Tags("UI_SelectedEquipment").Write CStr(equipmentId)
HMIRuntime.Tags("UI_SelectedPrefix").Write prefix
End SubInternal context tags are one possible pattern. Faceplate interfaces or picture-window properties may provide a cleaner supported mechanism in the installed release.
5. Bind the detail view consistently
The reusable view should read its approved context once, validate it and then bind captions, states and commands through a documented interface.
- Display the equipment identifier and description prominently.
- Use separate feedback and command tags.
- Show unavailable or bad-quality states explicitly.
- Reset stale context when the view closes.
6. Open the supported picture or popup
Use the documented WinCC function for the deployed edition. Keep the navigation request in one reusable function so version-specific calls are not duplicated throughout the project.
Sub OpenMotorDetail(ByVal equipmentId)
Call SelectEquipment(equipmentId)
'Call the supported picture-window or popup method here.
HMIRuntime.Trace "Motor detail requested: " & _
CStr(equipmentId) & vbCrLf
End Sub
7. Design multi-instance faceplate commands safely
A reusable faceplate should submit a request for the selected instance, not write directly to an arbitrary constructed tag.
- Resolve the selected instance against the approved equipment map.
- Verify the current view still represents that instance.
- Apply WinCC authorization and operator confirmation where required.
- Write the request to the documented interface.
- Display the PLC acknowledgment or rejection reason.
8. Prevent stale context and navigation faults
| Failure mode | Prevention or diagnostic |
|---|---|
| Wrong motor details shown | Display and trace the resolved identifier and prefix |
| Old popup context remains | Initialize context on open and clear it on close |
| Duplicate popups | Check instance state before opening another |
| Object required error | Confirm active picture, window and exact object name |
| Navigation loop or dead end | Test every entry, close and return path |
9. Commission the reusable instance design
- Test every approved equipment identifier.
- Attempt an unknown identifier and confirm it is rejected.
- Change screens rapidly and verify context does not cross between instances.
- Test communication loss, user logout and PLC command rejection.
- Document the faceplate interface, tag map and version.
10. Example: one motor faceplate for three conveyors
An overview contains motors M101, M102 and M103. Selecting a motor resolves its approved prefix, updates the internal context and opens the same motor-detail view. The faceplate displays feedback, mode and fault information for that instance while command requests still pass through PLC validation.
Frequently asked questions
Should tag names be built directly from operator input?
No. Resolve a selected equipment identifier through an approved map or supported faceplate interface.
Why use one reusable faceplate?
It provides consistent behavior and reduces duplicated screens, but it also requires disciplined context validation and version control.
Can the popup method be copied between all WinCC editions?
No. Navigation and popup APIs vary. Verify the exact method in the installed product documentation.
