Resolving Wrong Recipe Name in TIA Portal HMI GetDataRecordName

David Krause13 min read
HMI / SCADASiemensTroubleshooting
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Resolving Wrong Recipe Name in TIA Portal HMI GetDataRecordName

Problem Description: Recipe Name Not Updating After LoadDataRecord

In TIA Portal HMI (WinCC Comfort, WinCC Advanced, or WinCC Unified) projects that use the Recipe view (Advanced view) element together with a custom button-driven recipe selection, recipe values load correctly to the PLC, but the displayed data record name remains incorrect. Three buttons select three different recipes (A, B, C). Pressing each button calls LoadDataRecord followed by GetDataRecordName. The PLC tags receive the correct values, but the HMI screen continues to show the previously cached recipe name until the operator navigates to another picture and returns.

Observed symptom stack in the field:

  • Recipe data record is correctly written to PLC tags (verified via watch table or tag monitor).
  • The Recipe view (Advanced) shows the previous data record name in the title bar, status line, or selection list.
  • The displayed name only updates after a manual picture change (screen navigation away and back).
  • Reproduction is deterministic: every LoadDataRecord call leaves the cached name stale.
  • Recipe values written to the PLC remain correct on every press; only the displayed name is wrong.
Scope: This article applies to SIMATIC HMI panels configured in TIA Portal V15, V15.1, V16, V17, V18, and V19 using the Recipe view element and the recipe system functions exposed under the HMI scripts library. The same behavior is observed on WinCC Runtime Advanced (PC-based), WinCC Professional / RT Professional, and on Comfort Panels (TP700 to TP2200). Unified Comfort Panels (MTP series) follow a different scripting model and are addressed in the FAQ.

Root Cause: Asynchronous System Functions and HMI Cache Update Timing

The recipe system functions LoadDataRecord, GetDataRecordName, GetRecipeName, SaveDataRecord, GetDataRecord, and SetDataRecord are asynchronous on TIA Portal HMI. They schedule a job on the HMI Runtime recipe task; the function returns immediately to the calling script, and the actual transfer from the recipe database to the PLC tags is performed by the recipe task in the background. The ProcessingStatus parameter reports the state of this background execution.

When a VBScript calls LoadDataRecord and then GetDataRecordName synchronously in the same execution thread, the second call is dispatched before the recipe task has updated the internal HMI recipe cache that the Recipe view element reads from. The result is a stale data record name even though the PLC has already received the new values.

The data record name is stored in the HMI's internal recipe cache, not in the PLC. The Recipe view (Advanced) element does not poll this cache continuously; it only re-reads the cache on picture activation, on screen refresh events, or on explicit ActivateScreen / ChangePicture triggers. Because the cache is updated asynchronously by the recipe task, calling GetDataRecordName immediately after LoadDataRecord returns the name from the previous state. PLC values are written by the recipe task through the S7 connection in the same job, but the cache write-back and the Recipe view element refresh are decoupled events.

Affected HMI Platforms and Firmware Versions

HMI Platform TIA Portal Version Image / Firmware Status
Comfort Panels (TP700, TP900, TP1200, TP1500, TP1900, TP2200) V15 .. V19 WinCC Comfort / Advanced V15 .. V19 Reproducible
WinCC Runtime Advanced (PC-based, IPC227G, IPC277G, IPC477) V15 .. V19 WinCC Runtime Advanced V15 .. V19 Reproducible
Unified Comfort Panels (MTP700, MTP1000, MTP1200, MTP1500, MTP1900, MTP2200) V16 .. V19 WinCC Unified Comfort V16 .. V19 Different API; same symptom possible
WinCC Professional / RT Professional (TIA Portal) V15 .. V19 WinCC Professional V15 .. V19 Reproducible
Basic Panels (KTP400, KTP700, KTP900, KTP1200) V15 .. V19 WinCC Basic V15 .. V19 Limited (no advanced Recipe view element)

The behavior is independent of the HMI image version. It is a function-call timing issue rooted in the asynchronous recipe task scheduler that all WinCC V15+ runtimes share.

ProcessingStatus Return Value Reference

The third parameter of every recipe system function returns the current processing status of the recipe task. Always poll this parameter to confirm completion before reading derived data such as the data record name. The status values documented by Siemens for the recipe system functions are:

Value Meaning Engineering Action
2 System function is being performed (job is running on the recipe task) Do not read derived data; poll status in a loop
4 System function was successfully completed Terminal success; safe to call GetDataRecordName
12 System function was not performed because an error occurred Terminal failure; check the HMI diagnosis view for the cause
Critical: Status 2 indicates the recipe task is still in progress. Status 4 is the only value that confirms the cache is updated and the data record is safe to read. Status 12 indicates an error during the transfer; the cache is not updated. Do not assume the load succeeded when status 2 is observed; the script may exit before the recipe task completes.

Solution 1: Do-While Loop Synchronization Pattern

The most reliable fix is to wait for the recipe task to complete before reading the data record name. Use a Do While loop in VBScript to poll ProcessingStatus until the job leaves the running state (2). This blocks the HMI script thread until the asynchronous load has finished, after which the cache is consistent and GetDataRecordName returns the correct value.

' VBScript example for a TIA Portal HMI button "Click" event
Dim sRecipeName
Dim iStatus

' Trigger the load (Recipe 1, DataRecord 1, status variable)
LoadDataRecord 1, 1, iStatus

' Wait for the recipe task to leave the running state
Do While iStatus = 2
Loop

' Now the HMI cache is consistent
GetDataRecordName 1, 1, sRecipeName, iStatus

' Display the name on an HMI tag
SmartTags("Recipe_DisplayName") = sRecipeName

The loop pattern works because VBScript execution on the HMI Runtime is single-threaded for the script engine, and the recipe task updates ProcessingStatus in a memory location the script can read. While the loop is running, the HMI RT scheduler can still dispatch the recipe task completion; the script continues only after status moves off 2.

Caution: A do-while loop blocks the HMI event dispatcher and freezes the screen for the duration of the load. On slow networks or with large recipes (more than 50 elements, or recipes crossing S7 connection boundaries), the freeze can be noticeable. Keep the recipe data records small, or schedule the load in a scheduled task and use a status tag to drive the button enable state instead of blocking the UI thread.

Solution 2: Forced Screen Refresh After Recipe Load

If the loop pattern is unsuitable (for example, on a Basic Panel with a restricted VBScript engine, or in a Unified HMI where the script model differs), force a screen refresh by calling the picture again. The Recipe view element re-reads the recipe cache on picture activation, so navigating away and back updates the displayed name.

' VBScript pattern: change picture to itself
' "Picture_RecipeView" is the current screen name
ActivateScreen "Picture_RecipeView", 0

For panels that do not support VBScript, configure the button event with three actions in sequence: first LoadDataRecord, then a ChangePicture to an intermediate dummy screen, then a ChangePicture back to the recipe view. The intermediate screen can be a black screen with no controls. The Recipe view element re-initializes on every activation and reads the new data record name from the cache.

Field-tested sequence for a Comfort Panel without VBScript (configured in the button "Click" event properties):

  1. System function LoadDataRecord with the configured recipe and record numbers.
  2. Function ChangePicture to Picture_Blank.
  3. Function ChangePicture back to Picture_RecipeView (with optional tag-pluggable parameters).

Solution 3: Tag-Based Name Display Decoupling the Recipe View

For panels where the Recipe view element cannot be replaced, bind a separate text element to an HMI tag that is set from GetDataRecordName after the load completes. This decouples the name display from the Recipe view element's internal cache and is the most robust approach for production panels.

' After LoadDataRecord completes (use status loop or scheduled task)
GetDataRecordName 1, 1, sRecordName, iStatus
Do While iStatus = 2
Loop
If iStatus = 4 Then
    SmartTags("Recipe_DisplayName") = sRecordName
End If

Bind a text field to Recipe_DisplayName instead of relying on the Recipe view's internal title. The text field updates whenever the tag changes, regardless of the Recipe view's cache state. This pattern also enables logging of the loaded recipe name to a recipe-load audit tag for traceability.

Complete Working Script Example

The following script combines the loop pattern, status check, and tag update. Drop it into a button's "Click" event in the TIA Portal HMI editor.

' === Load Recipe button click handler (TIA Portal HMI VBScript) ===
Dim iRecipeNumber       ' INT, 1..n
Dim iRecordNumber       ' INT, 1..m
Dim iStatus             ' INT, status return value
Dim sRecordName         ' STRING, data record name buffer
Dim sRecipeName         ' STRING, recipe name buffer

iRecipeNumber = SmartTags("Button_RecipeIndex")
iRecordNumber = SmartTags("Button_RecordIndex")

' 1. Trigger the load
LoadDataRecord iRecipeNumber, iRecordNumber, iStatus

' 2. Block until the recipe task leaves the running state
Do While iStatus = 2
Loop

' 3. Evaluate the terminal status
Select Case iStatus
    Case 4  ' Success
        ' 3a. Read the data record name
        GetDataRecordName iRecipeNumber, iRecordNumber, sRecordName, iStatus
        Do While iStatus = 2
        Loop
        If iStatus = 4 Then
            SmartTags("Recipe_DisplayName") = sRecordName
        End If
        ' 3b. Read the recipe name (for display)
        GetRecipeName iRecipeNumber, sRecipeName, iStatus
        Do While iStatus = 2
        Loop
        If iStatus = 4 Then
            SmartTags("Recipe_DisplayRecipeName") = sRecipeName
        End If
    Case 12 ' Error
        SmartTags("Recipe_LoadError") = True
        SmartTags("Recipe_DisplayName") = "ERROR"
    Case Else
        SmartTags("Recipe_DisplayName") = "STATUS=" & iStatus
End Select
Field note: Always define SmartTags("Button_RecipeIndex") and SmartTags("Button_RecordIndex") in the HMI tag table before wiring the script. Use one button per recipe/record combination, or set the indexes from the button's "Click" event properties and read them in the script. Avoid calling GetDataRecordName with hard-coded constants in production; always parameterize.

Recipe View (Advanced) Configuration Notes

The Recipe view (Advanced) element in TIA Portal HMI has a "Data record name" display field bound to the recipe cache, not to a configurable HMI tag. This is why the name does not update on tag change: the cache is updated by the recipe task scheduler, and the view reads the cache on the next refresh event.

To work around this without replacing the Recipe view, do one of the following:

  1. Use a separate text element bound to a tag for the name display, and set the tag from GetDataRecordName after the load completes (Solution 3 above).
  2. Force a screen refresh by navigating away and back, or by calling ActivateScreen with the current screen name (Solution 2 above).
  3. Replace the Recipe view (Advanced) with a custom screen layout that reads recipe data through HMI tags and updates the name field from GetDataRecordName after synchronization.

For the complete reference on Recipe view configuration, recipe elements, and recipe data records, consult the TIA Portal Help under "Visualizing processes > Recipes > Working with recipes > System functions for recipes" and the Siemens support entry on WinCC recipe handling: Siemens Industry Online Support.

PLC Tag Mapping and S7 Communication

Recipe elements are mapped to PLC tags in the recipe configuration under "Recipes > [Recipe Name] > Elements". The mapping is one-way: HMI to PLC during load, PLC to HMI during save. Ensure that the connection to the PLC is configured with sufficient update rate for the tags to be visible in the HMI tag table within the same scan cycle the recipe task completes.

For S7-1200 and S7-1500 PLCs, the recipe transfer is performed over the HMI connection (S7 Communication / S7 PUT/GET or symbolic access). Default update settings on the connection are sufficient for typical recipes. If the recipe contains more than 100 elements, raise the "Update" cycle in the HMI connection properties from 1 s to 100 ms or shorter to keep the PLC tags in sync with the recipe task completion. For S7-1500 with optimized block access, ensure that the recipe tags are configured with the "Accessible from HMI" attribute in the PLC tag table; otherwise the recipe element mapping fails with status 12.

S7-300 and S7-400 PLCs use the same S7 Communication protocol; the recipe transfer behavior is identical. Older SIMATIC Panels (MP277, MP377) running older WinCC Flexible images are not covered by this article; the recipe API differs and the same fix may not apply.

Verification Steps

After applying the fix, verify on the live panel or in the HMI simulation (RT):

  1. Configure a watch table in TIA Portal for the PLC tags written by the recipe. Set a breakpoint or trigger on the tag change.
  2. Open the HMI simulation (RT) or the actual panel in commissioning mode.
  3. Click each of the three recipe buttons (A, B, C). Confirm:
    • The PLC tags update to the expected values (visible in the watch table within one update cycle).
    • The HMI screen displays the correct data record name immediately, without a manual picture change.
    • The Recipe_DisplayName HMI tag contains the expected string.
  4. Press the button repeatedly in quick succession. Confirm the name is correct on every press, not only on the first.
  5. Disconnect and reconnect the HMI connection. Confirm the recipe name still updates correctly after reconnection.
  6. Power-cycle the HMI panel. Confirm the recipe name still updates correctly on the first load after power-up.
  7. Run a long-duration test (1 hour) with continuous button presses to confirm no memory leaks in the loop pattern.

Alternative Recipe Management Approaches

For SCADA-class recipe management with versioning, audit trails, approval workflows, and cross-line recipe distribution, consider AVEVA Recipe Management (formerly Wonderware). The product reduces recipe management effort and automates formula download and recipe execution on automated equipment. Refer to the product page for the supported SCADA hosts, OPC UA integration, and the recipe approval workflow: AVEVA Recipe Management - Powered by Wonderware.

For typical machine-level recipes (a few dozen data records, no versioning, no approval flow), the TIA Portal HMI recipe system is sufficient and the fixes above resolve the data record name display issue without changing the recipe management platform. Migrating to AVEVA Recipe Management is recommended only when the recipe count, lifecycle, or audit-trail requirements exceed what the built-in HMI recipe system can deliver.

FAQ

Why does LoadDataRecord succeed but GetDataRecordName return the previous recipe name?

The two system functions run on the HMI Runtime recipe task, which is asynchronous. LoadDataRecord returns immediately; the recipe task writes to the PLC and updates the internal cache in the background. GetDataRecordName reads the cache, so calling it before the cache is updated returns the previous name. Wait for ProcessingStatus to leave value 2 (running) before calling GetDataRecordName, or call ActivateScreen with the current screen name to force the Recipe view to re-read the cache.

What does ProcessingStatus value 2, 4, and 12 mean for recipe system functions?

Value 2 means the system function is currently being performed (running). Value 4 means the system function completed successfully. Value 12 means the function was not performed because an error occurred. Always poll until the status is 4 or 12, never read derived data while the status is 2.

Can I use a do-while loop to synchronize recipe loads in TIA Portal HMI VBScript?

Yes. Use Do While ProcessingStatus = 2 : Loop after the LoadDataRecord call. The loop blocks the script thread until the recipe task leaves the running state. The script continues only after the cache is updated, and subsequent GetDataRecordName returns the correct name. Avoid the pattern for very large recipes because the screen freezes for the duration of the loop.

Does the Recipe view (Advanced) automatically refresh the data record name when the recipe changes?

No. The Recipe view (Advanced) reads the data record name from the HMI's internal recipe cache on picture activation and on screen refresh events. It does not continuously poll the cache. To make the name update immediately after a programmatic recipe load, force a screen refresh by calling ActivateScreen with the current screen name, or set a separate HMI tag from GetDataRecordName and bind a text element to that tag.

Are the same recipe system functions available on Unified Comfort Panels?

Unified Comfort Panels use a different API based on JavaScript and the Unified Runtime recipe interface. The legacy LoadDataRecord and GetDataRecordName VBScript functions are not available on Unified. Use the Unified recipe functions HMIRuntime.Recipe and the related methods in a Unified screen script. The same synchronization principle applies: wait for the asynchronous load job to complete before reading the data record name.

Back to blog