1. Problem Statement
The Siemens SIMATIC HMI Recipe View object (WinCC flexible 2008 Compact / Standard / Advanced and TIA Portal WinCC Comfort / Advanced / Professional) is a closed, self-contained ActiveX-like container. It manages its own internal recipe database, its own display columns, and its own selection highlight. Unlike a standard IO Field, Symbolic I/O Field, or List Box, the Recipe View does not expose:
- An index or handle for the currently focused row / column inside the view.
- A property analogous to
SelectedIndexorCurrentRowon a Windows list control. - A tab-order or
TabIndexthat the engineer can read at runtime to determine which recipe element the operator is editing.
The result is a real engineering gap: an application that needs to drive downstream logic from the operator's selection (for example, logging which field was changed, highlighting the modified value in a separate trend, gating a write to the PLC until the operator confirms a specific column, or building a custom audit trail) cannot bind directly to a Recipe View property, because that property does not exist in the public object model.
2. Recipe View Object Model and Available Properties
Before attempting any workaround, the engineer must understand exactly which properties the Recipe View does expose. The relevant properties, in both WinCC flexible 2008 and TIA Portal, are limited to the recipe itself, not to an individual element inside a data record.
| Property / Method | Scope | Returns | Notes |
|---|---|---|---|
RecipeName |
Recipe view | Name of the active recipe | Set in Recipes editor |
DataRecordName |
Recipe view | Name of the active data record | Loaded from internal DB or PLC |
DataRecordNumber |
Recipe view | Index of the active data record | 1..n as configured |
ReadDataRecordFromPLC |
Function | Status / error code | Direction: PLC → HMI |
SaveDataRecordToPLC |
Function | Status / error code | Direction: HMI → PLC |
GetDataRecordNameFromPLC |
Function | Status / error code | Used to enumerate available records |
DeleteDataRecord |
Function | Status / error code | Removes a record from HMI storage |
| Synchronize tags (option) | Recipe | Mirrors element values to external tags | Configured in the Recipes editor |
Notice what is missing: there is no CurrentElement, SelectedRow, FocusIndex, or ActiveColumn. The selection focus is private state of the embedded recipe database, and it is not surfaced to the rest of the runtime.
SaveDataRecord programmatically). Polling the internal recipe database from a script is also not supported.3. Method 1 — Synchronize Tags (Recommended Workaround)
The cleanest and most maintainable approach is to enable tag synchronization on the recipe. When synchronization is enabled, every recipe element value is mirrored to a tag of the same name defined outside the recipe. The script layer can then poll those tags and infer selection state by comparing the current value against a stored baseline.
3.1 Configuration Steps
- Open the Recipes editor in the WinCC flexible 2008 project tree (or the equivalent in TIA Portal: Recipes → Recipe elements tab, as documented in the TIA Portal V20 manual at Creating Recipe Elements and Data Records (RT Professional)).
- Select the recipe you want to monitor.
- Open the Properties dialog and switch to Synchronize.
- Tick Synchronize tags. Confirm the warning that the runtime will overwrite the named external tags whenever a data record is loaded.
- Verify that every recipe element has a tag of matching name in the tag editor. Unmapped elements will not be synchronized.
- Build the project, download to the panel, and verify on the panel that opening a record updates the external tags in the tag monitor.
3.2 Selection Inference Logic
With synchronized tags, the engineer can run a scheduled VBScript (or a C-script in WinCC flexible 2008) that detects which element the operator has just edited by comparing the synchronized values to a snapshot taken immediately after the data record was loaded:
' WinCC flexible 2008 VBScript
' Triggered by a "Data record loaded" event of the Recipe View.
Sub OnDataRecordLoaded(ByVal RecipeName, ByVal DataRecordName)
Dim tags, i
tags = Array("HMI_Recipe_Elem_01", _
"HMI_Recipe_Elem_02", _
"HMI_Recipe_Elem_03", _
"HMI_Recipe_Elem_04")
For i = 0 To UBound(tags)
SmartTags("Baseline_" & tags(i)) = SmartTags(tags(i))
Next
SmartTags("Baseline_Loaded") = True
End Sub
' Scheduled script, 100 ms cycle.
Sub OnCycle100ms()
If Not SmartTags("Baseline_Loaded") Then Exit Sub
Dim tags, i
tags = Array("HMI_Recipe_Elem_01", _
"HMI_Recipe_Elem_02", _
"HMI_Recipe_Elem_03", _
"HMI_Recipe_Elem_04")
For i = 0 To UBound(tags)
If SmartTags(tags(i)) <> SmartTags("Baseline_" & tags(i)) Then
SmartTags("Changed_Element_Index") = i + 1
SmartTags("Changed_Element_Name") = tags(i)
End If
Next
End Sub
The variable Changed_Element_Index now contains a 1-based index of the element the operator most recently modified. The variable updates only when the operator actually changes a value; cursor movement alone does not produce a delta.
4. Method 2 — Save-Event Change Tracking
If the application only needs to know which element was changed at the moment the operator presses Save, a far simpler solution exists. Wire a VBScript to the SaveDataRecord event of the recipe view, then compare each synchronized tag against the original value stored in the PLC.
4.1 PLC-Side Original Value Buffer
The PLC keeps a DB block (e.g., DB 200, "Recipe_Original") that mirrors the data record before any operator edit. Whenever LoadDataRecord succeeds, the HMI also writes the loaded values to this DB. The PLC never overwrites it again until the next LoadDataRecord.
// S7-1200 / SCL in TIA Portal
FUNCTION_BLOCK FB_RecipeShadow
VAR
bLoaded : BOOL;
END_VAR
BEGIN
IF "HMI_Cmd_Load" THEN
// Copy the active recipe DB into the shadow DB
"DB_Recipe_Shadow" := "DB_Recipe_Active";
bLoaded := TRUE;
END_IF;
END_FUNCTION_BLOCK
4.2 HMI-Side Save-Event Script
' WinCC flexible 2008 / TIA Portal VBScript on the recipe view
Sub OnSaveDataRecord(RecipeName, DataRecordName)
Dim elements, i, changedList
elements = Array("Elem_01","Elem_02","Elem_03","Elem_04")
changedList = ""
For i = 0 To UBound(elements)
If SmartTags(elements(i)) <> _
SmartTags("PLC_" & elements(i)) Then
changedList = changedList & elements(i) & ";"
End If
Next
SmartTags("Last_Changed_List") = changedList
SmartTags("Last_Save_Recipe") = RecipeName
SmartTags("Last_Save_Record") = DataRecordName
End Sub
This method answers the second question raised in the original engineering thread: after the operator saves a data record, which element was changed? The answer is captured in Last_Changed_List, indexed by element name, populated only at the moment of save.
5. Method 3 — Recipe Element Polling via PLC Array
When the recipe contains many elements and tag synchronization is undesirable, the recipe can be mirrored to a PLC array of a UDT with a changed flag. The HMI sets a dirty bit on every element whenever the operator presses Enter inside that element. This requires giving up the default Recipe View and replacing it with a custom screen built from individual IO Field objects, but it gives the engineer true control.
| UDT field | Type | Meaning |
|---|---|---|
Value |
REAL / INT / STRING | Current value of the element |
Original |
REAL / INT / STRING | Value at load time |
bTouched |
BOOL | TRUE if operator edited and pressed Enter |
szName |
STRING[32] | Element name (e.g. "Setpoint_Temp") |
This is the technique used in most large-scale pharmaceutical and Tier-1 automotive Recipe View replacements, where 21 CFR Part 11 / FDA audit-trail requirements mandate per-element change capture.
6. Method 4 — "Operator Touch" via Focus Color Trick
A lightweight, non-invasive trick uses Recipe View appearance changes. Add a focus event (where supported) that flips a global tag whenever the recipe view becomes active. Then use the synchronized tag baseline method (Method 1) but only evaluate deltas while the focus tag is TRUE. This reduces the number of false positives caused by other screens modifying the same tags.
7. RT Professional Differences (TIA Portal V20 and Later)
The TIA Portal RT Professional recipe view is a re-implementation based on the same WinCC Professional runtime, not on the WinCC flexible Compact engine. Its public object model is closer to .NET / WPF, but the public surface is still focused on the recipe and the data record, not on individual element selection.
| Feature | WinCC flexible 2008 / TIA Comfort-Advanced | TIA Portal V20 RT Professional |
|---|---|---|
Public CurrentElement property |
Not available | Not available |
| Tag synchronization | Yes, per recipe | Yes, per recipe |
| Custom event "ElementChanged" | No | No (as of V20) |
| Recipes editor tab | One tab "Recipe elements" | One tab "Recipe elements" (see Creating Recipe Elements and Data Records (RT Professional)) |
| Recommended workaround | Synchronize tags + scheduled script | Synchronize tags + scheduled script |
Migration from WinCC flexible 2008 to TIA Portal does not change the answer to the original question: there is no native property, and the synchronized-tag workaround is still the cleanest path. Engineers upgrading from WinCC flexible 2008 to TIA Portal should consult the WinCC flexible 2008 manual chapter 8.1.6 for legacy semantics, then the TIA Portal manual for the equivalent Recipes editor behavior.
8. Edge Cases and Operator Workflows
- Tabbing through fields without editing. Synchronized tags are unchanged. The script does not fire. This is the desired behavior.
- Edit and revert. The operator types a value, then restores the original. Because the baseline was captured on load, the script will still record a transient change. Add a debounce of one polling cycle if your environment sees flicker from rapid edits.
- Multi-language recipe element labels. Synchronization is by element name, not by display text. Localized labels do not affect the script.
-
Concurrent loading. If a PLC-driven
ReadDataRecordFromPLCruns while the operator is editing, the baseline script must re-arm. Wire the re-arm to the Data record loaded event, not to a tag value change. -
Tag name collisions. If a recipe element is renamed, the synchronized tag is orphaned. Use a naming convention such as
HMI_Rcp_<RecipeName>_<ElementName>to avoid collisions with PLC tags. - RT Professional with faceplates. Wrap the recipe view in a faceplate only if the faceplate exposes the synchronized tags. Embedding the Recipe View directly inside a faceplate does not change its selection behavior.
9. Verification and Acceptance Test
- Open the HMI tag monitor. Load data record 1. Confirm that all synchronized tags take the loaded values.
- Place a breakpoint or
MsgBoxin the Data record loaded script. Confirm that baseline tags are populated. - Edit element 2 to a new value, then press Enter. Confirm that
Changed_Element_Indexbecomes 2 within one polling cycle. - Tab through elements 3 and 4 without editing. Confirm that
Changed_Element_Indexremains at 2. - Press Save. Confirm that
Last_Changed_Listcontains element 2. - Load data record 2. Confirm that the baseline is re-armed and
Changed_Element_Indexis reset. - Cycle power to the panel. Confirm that the script re-arms the baseline on the first data record load after restart.
- Repeat with a non-editable read-only recipe view. Confirm that the script does not fire (the operator cannot change a value).
If all eight steps pass, the workaround is field-ready. Document the limitation in the project FRS / DDS so that the absence of a native CurrentElement property is not flagged as a defect during future audits.
10. Frequently Asked Questions
Does the WinCC Recipe View expose a property for the currently selected element?
No. In both WinCC flexible 2008 and TIA Portal (Comfort, Advanced, and RT Professional as of V20), the Recipe View exposes the active recipe name, the active data record name and index, and the standard load / save functions. There is no CurrentElement, SelectedIndex, or ActiveColumn property. The internal selection focus is private to the recipe database.
How do I detect which recipe element the operator just changed before they press Save?
Enable the recipe's Synchronize tags option, snapshot all synchronized values to a baseline array in the Data record loaded event, then run a scheduled script (100 ms is typical) that compares the current value of each synchronized tag to the baseline. The element whose value differs is the one the operator changed.
How do I detect which recipe element changed at the moment the operator presses Save?
Wire a VBScript to the recipe view's SaveDataRecord event. In the script, compare each synchronized tag to the value stored in the PLC (loaded by the previous ReadDataRecordFromPLC). Populate an audit tag with the names of every element whose value differs, plus a save timestamp.
Is there a way to select a specific recipe element on screen load, like setting the tab order of an IO field?
No. The original WinCC flexible 2008 Recipe View does not support a programmatic "set focus to element N" call. If element-level focus control is required, replace the Recipe View with a custom screen built from individual IO Field objects and manage focus through their standard TabIndex or Activate methods.
Does TIA Portal V20 RT Professional fix the missing selected-element property?
No. The TIA Portal V20 RT Professional Recipe View uses a different runtime but the same Recipes editor model. The element-level selection is still not exposed. The synchronized-tag + scheduled-script workaround is still the recommended approach. Refer to the TIA Portal V20 documentation page Creating Recipe Elements and Data Records (RT Professional) for the editor layout.
What is the chapter reference for Recipe View behavior in WinCC flexible 2008?
Chapter 8.1.6 "Working with Recipes" of the SIMATIC HMI WinCC flexible 2008 Compact / Standard / Advanced manual covers the Recipe View object model, the synchronize-tags option, and the available system functions (ReadDataRecordFromPLC, SaveDataRecordToPLC, GetDataRecordNameFromPLC, DeleteDataRecord). Always verify the chapter number and content against your installed version of the manual.