Overview
WinCC Unified (TIA Portal V17 and later, including the current V20 release line) exposes a fundamentally different scripting model for screen objects than WinCC V7 or WinCC Professional (Comfort). The legacy InputValue property and the InputValueChanged event do not exist on the Unified IO field object. Engineers migrating automation code, validation routines, or computed-write logic from V7/Comfort panels to Unified Runtime (RT Unified) panels or PC-based Unified Stations frequently discover that the familiar property/event pair is gone, and an attempt such as item.InputValue.set(...) silently throws an undefined reference at runtime.
The Unified replacement pattern uses two distinct touch points on the IO field screen object:
- The ProcessValue property — used for reading the tag into the field on every cycle (visualization, output direction).
- The InputFinished event — fires once after the operator confirms input (Enter, focus loss, or configured termination). Inside this event handler the script must call
item.ProcessValue.set(...)to write the entered value back to the PLC tag.
This article documents the canonical Siemens-recommended JavaScript pattern, the Tags() collection access used for both directions, and the complete TIA Portal V20 configuration procedure for an RT Unified panel or Unified PC station. All code samples are written against the TIA Portal V20 scripting API as documented in the official Siemens TIA Portal Help and the WinCC Unified engineering manual.
Tags() collection, the ProcessValue property, and the InputFinished event behave identically on V17, V18, V19, and V20. Earlier Unified V16 RT also supports the same model but with a slightly older property set.Prerequisites
Before scripting an IO field input, verify that the engineering environment and runtime target meet the following requirements:
- TIA Portal: V17, V18, V19, or V20 with the WinCC Unified ES package installed. The screenshots and scripting interface in this article correspond to V20.
- Runtime target: Either an RT Unified panel (e.g., MTP700 Unified Comfort, SIMATIC HMI Unified Comfort Panels) or a Unified PC station running WinCC Unified Runtime V17+.
-
Configured HMI tag: A valid HMI tag, e.g.
Tag101, of a numeric data type (Int,DInt,Real,LReal) connected to a PLC tag or DB element. Tags of typeString,WString, andBoolare supported by the same API but with type-specific input format handling. - Script runtime enabled: Project tree → Runtime settings → Script runtime → "Global script runtime" enabled. JavaScript runtime support ships with WinCC Unified by default; no additional option is required.
- User authorization: The operator who should be permitted to write to the tag via the IO field must have an authorization level that allows write access. Configure in User Administration → Users & Roles. By default, the "HMI Operator" role grants read/write; deny explicit if read-only access is required.
Why the Original item.InputValue.set() Approach Fails
The script the source engineer tried — item.ProcessValue.set( Tags("Tag101") ) — is directionally correct but was placed on the wrong event and conflated the read direction. In WinCC Unified, the IO field screen object exposes the following relevant members in its scripting interface:
| Member | Direction | Type | Purpose |
|---|---|---|---|
ProcessValue |
Read/Write | Property (Variant) | Live value shown in the field. Read on every cycle; written only from inside InputFinished or other scripts. |
OutputValue |
Read-only | Property (Variant) | Display formatting of the current value (mirrors ProcessValue). |
InputFinished |
Write trigger | Event | Fires after operator confirms input. Receives value argument with the entered text/number. |
InputValueChanged |
n/a | Does NOT exist in Unified | Legacy WinCC V7/Professional event; will throw a runtime error if referenced in a Unified script. |
Placing item.ProcessValue.set(...) on a cyclic trigger (such as the property itself) creates a write-back loop that continuously re-pushes the PLC value into the property. While the IO field then displays correctly, the operator can never enter a new value because the cycle overwrites the buffer before the runtime confirms input. The proper anchor is a one-shot event: InputFinished.
InputFinished event.Step-by-Step: Configure the IO Field and Script
The following procedure creates an IO field bound to a tag via JavaScript, covering both directions with a validation example. The procedure is identical for Comfort Unified panels, IPCs running Unified Runtime, and Unified PC stations.
Step 1 — Add the IO Field to the Screen
- In the TIA Portal project tree, expand HMI → Screens and open the target screen (e.g.,
Screen_1). - From the Toolbox palette, drag an IO field onto the canvas.
- Select the IO field and open the Properties pane. Under General → Process value, leave the field empty (no direct tag dynamization). Scripting requires that the process value is not statically linked; otherwise the script dynamization on the property is ignored.
- Set Mode to Input/output (read/write). For read-only display use Output; for write-only configuration use Input.
- Configure Format according to the data type: e.g.
999for an Int,9999.99for a Real with two decimals, ors9999for signed values. - Confirm with OK. The IO field now displays "###" or a placeholder because it has no dynamization yet.
Step 2 — Add a Read Dynamization Script on ProcessValue
- With the IO field selected, navigate to Properties → Events and scripts → ProcessValue → Script (or right-click the ProcessValue row → "Add script" in older UI revisions).
- The script editor opens. Enter the following minimal read script:
// Read dynamization: pull the current PLC value into the IO field each cycle.
// This is the canonical output-direction pattern in WinCC Unified.
let src = Tags("Tag101");
src.Read();
return src.Value;
- Close the script editor. Compile the project (Project → Compile → Software (rebuild all)). The IO field should now display the live value of
Tag101at the configured refresh rate.
src.Read() explicitly ensures a synchronous read of the tag buffer. For HMI tags connected via S7 communication the implicit refresh from the connection is usually sufficient; for OPC UA or named-tag connections the explicit Read() guarantees the latest value before it is returned.Step 3 — Add the InputFinished Event Handler (Write Direction)
- Select the IO field, then go to Properties → Events and locate Input finished.
- Click the row to add a script. The editor opens with the event signature pre-populated; the runtime passes the entered value as the argument
value. - Enter the canonical write script:
// InputFinished handler: write the operator's entry back to the PLC tag.
// The "value" parameter is provided automatically by the WinCC Unified runtime.
let dest = Tags("Tag101");
dest.Write(value);
return;
- Compile and download to the RT Unified target.
This pair of scripts — read on ProcessValue, write on InputFinished — is the direct replacement for the missing InputValue / InputValueChanged pair from WinCC V7.
Step 4 — Optional: Add Input Validation
The most common reason to script an IO field in the first place is to validate or transform the entry before it reaches the PLC. Below is a field-proven example that bounds a numeric setpoint to 0…100, clamps out-of-range values, and rejects non-numeric input:
// Validated write: clamp a setpoint into the 0..100 range.
// "value" carries the operator's entry from the runtime.
let dest = Tags("Tag101");
let raw = Number(value);
if (Number.isNaN(raw)) {
// Non-numeric input — reject silently and surface a system event.
HMIRuntime.Trace("IO field: rejected non-numeric input: " + value);
return;
}
let clamped = raw;
if (clamped < 0) clamped = 0;
if (clamped > 100) clamped = 100;
dest.Write(clamped);
HMIRuntime.Trace("IO field: wrote " + clamped + " to Tag101");
For string tags, swap Number(value) for a length check or regex validation, e.g. /^[A-Za-z0-9_]{1,16}$/.test(value).
Step 5 — Optional: Trigger a Derived Tag in Parallel
A frequent application is to write the entered value to two tags (e.g., setpoint and a "setpoint accepted" handshake). Both writes can be issued from the same InputFinished handler:
let setpoint = Tags("Tag101");
let acknowledge = Tags("Tag101_Ack");
setpoint.Write(value);
acknowledge.Write(true);
// Pulse-style: reset the acknowledge flag 500 ms later via a scheduled action.
HMIRuntime.Schedule(
function () { acknowledge.Write(false); },
500,
HMIRuntime.ScheduleOnce
);
HMIRuntime.Schedule(callback, ms, mode) with mode = HMIRuntime.ScheduleOnce fires once after the delay. Use HMIRuntime.SchedulePeriodic for repeating timers. Misuse of periodic schedules is the most common source of runaway CPU load on Unified PC stations.Properties Reference for IO Field (RT Unified, TIA Portal V20)
The following table summarizes the IO field screen object properties exposed to the WinCC Unified scripting runtime. All members are accessed on the item reference that the script editor implicitly passes into the handler.
| Property / Event | R/W | Type | Notes |
|---|---|---|---|
ProcessValue |
R/W | Variant | Live value; default member for read dynamization. Setting it from InputFinished writes through to the bound tag if a direct dynamization exists, or remains purely script-side if no dynamization is configured. |
OutputValue |
R | Variant | Current display value, formatted via the configured pattern. Read-only. |
Enabled |
R/W | Bool | Disable input at runtime (operator lockout, machine not ready, etc.). |
Visible |
R/W | Bool | Hide the field based on context. |
Tooltip |
R/W | String | Dynamically set tool tip text. |
BackColor / ForeColor
|
R/W | UInt32 (BGR) | Use HMIRuntime.Color.RGB(r,g,b) for readability. |
Quality |
R | UInt32 | OPC quality code of the bound tag — use for stale-value detection. |
Event: InputFinished
|
— | Event | Signature: function(value). Fires once after operator input is committed. |
Event: InputCancelled
|
— | Event | Fires if operator cancels (Esc key). Useful for cleanup or "no change" logging. |
Complete Working Example: S7-1500 Setpoint IO Field
The following end-to-end example ties a TIA Portal V20 project to a SIMATIC S7-1500 CPU. The PLC exposes a DB element "Setpoint_SP" of type Real; the HMI tag Tag101 is connected via an HMI connection with the standard S7 naming convention.
PLC side (S7-1500, TIA Portal V20):
// DB "HMI_Data", element "Setpoint_SP" : Real; // Tag address DB10.DBX0.0 REAL
// Optional: handshake bit for write confirmation
// "Setpoint_New" : Bool; // DB10.DBX4.0
HMI side, IO field on Screen_1:
- Mode: Input/output
- Format pattern:
9999.9 - Process value dynamization (script, Property → Script):
let src = Tags("Tag101");
src.Read();
return src.Value;
- InputFinished event (script):
let dest = Tags("Tag101");
let raw = Number(value);
if (Number.isFinite(raw)) {
// Round to one decimal to match the format pattern.
let rounded = Math.round(raw * 10) / 10;
dest.Write(rounded);
HMIRuntime.Trace("Setpoint committed: " + rounded);
} else {
HMIRuntime.Trace("Setpoint rejected: " + value);
}
Verification
After downloading the project to the Unified Runtime target, verify the configuration using the following commissioning checklist:
-
Visual read: Confirm the IO field shows the current value of the S7 tag. If it stays at
###, the read script is not returning the value or the tag quality isBad. Check the tag's Quality property withTags("Tag101").Qualityin a temporary trace. -
Visual write: Tap the IO field, enter a value, and press Enter (or use the configured confirmation key). The display should remain at the entered value. If the value reverts to the previous PLC value, the
InputFinishedscript is not writing, or the operator role lacks write authorization. - PLC-side echo: Monitor the tag in the PLC using a watch table or the S7-1500 web server. The new value must appear within one HMI acquisition cycle (default 100 ms for cyclic tags on S7 connections).
-
Script trace: Open the Unified Runtime's diagnostic viewer or the WinCC Unified Control Panel → Logs and Traces. Confirm the
HMIRuntime.Trace(...)lines appear at the expected points. - Cycle-loop test: Force the PLC value to a known constant (e.g., 42.0) using the watch table, then enter a different value on the HMI. After confirmation, the HMI should display the entered value until the PLC has acknowledged it and updated the source — proving the write direction is functional and not being overwritten by the read dynamization.
Troubleshooting Matrix
| Symptom | Likely Root Cause | Corrective Action |
|---|---|---|
Field shows ###
|
Read script returns undefined; tag name typo; tag not connected. |
Verify tag name spelling in Tags("Tag101"). Confirm HMI connection status. Check tag quality. |
| Entered value disappears | Write script placed on a property instead of InputFinished; user lacks write authorization. |
Move write to InputFinished event. Verify operator role includes write access for the tag area. |
Runtime error: item.InputValue is undefined
|
Legacy WinCC V7 code carried into Unified. | Remove all references to InputValue and InputValueChanged. Use ProcessValue + InputFinished. |
| Field accepts input but PLC does not update | Wrong tag address; PLC connection broken; wrong HMI tag (e.g., internal tag instead of external). | In TIA Portal, open HMI tags and verify the connection assignment. Test the tag directly via a momentary button in the same screen. |
| Non-numeric input causes crash or stale display | Missing input validation; Number() coerces null to 0. |
Add Number.isFinite() / Number.isNaN() guard before Write(). |
| Field writes but value reverts after 1 s | A second dynamization (animation, faceplate, or another script) is overriding ProcessValue. |
Audit all scripts and animations touching ProcessValue. Only the read script on the property and the write script on InputFinished should reference it. |
| Input value not converted (e.g. "10,5" written as 105) | Locale mismatch between HMI decimal separator and PLC data type. | Set HMI runtime language decimal separator in Project → Languages & resources. Or normalize in the script: value.replace(",", ".") before Number(). |
Alternative: Direct Tag Dynamization (No Script)
If the only requirement is a plain read/write IO field with no validation, transforms, or secondary writes, the script layer is unnecessary. Configure as follows:
- Select the IO field, open Properties → General → Process value.
- Click the tag browser and select
Tag101. - Compile and download. The runtime handles read and write automatically; the operator can enter a value, press Enter, and the PLC receives it within the configured acquisition cycle.
This is the path Siemens recommends for straightforward setpoints. Reserve the scripting path for cases that require validation, derived writes, logging, conditional write enable, or non-linear mapping.
Best Practices and Field-Proven Caveats
-
Always coerce input. The
valueargument fromInputFinishedarrives as aString. Explicit conversion viaNumber(),parseInt(), orparseFloat()is required for numeric tags.nullbecomes0inNumber(); always guard withNumber.isFinite(). -
Avoid
Tags(...).ValueinInputFinishedwrites. Reading the current PLC value back throughTags(...).Valueinside a write handler is a common mistake that re-introduces a write-back loop on the same script. Write thevalueargument directly to the destination tag. - Use the same tag for read and write. The Unified runtime does not require separate read and write tags; a single tag drives both directions when the IO field is in Input/output mode.
-
Prefer
HMIRuntime.Tracefor commissioning. On Unified PC stations, traces appear in the diagnostic trace viewer accessible via the system tray. On Unified Comfort panels, traces are written to a rotating log on the SD card and downloadable via the panel's web server. -
Type-strict writes. Writing a
Realvalue to anInttag triggers a runtime conversion error. Validate not only the range but the data type compatibility. -
Authorization on writes. Even with the script in place, an operator without the correct role cannot write. Verify role assignments in the User Administration editor. The
InputFinishedevent fires regardless of role, but theWrite()call is rejected by the runtime. -
Format string alignment. The IO field display format and the validation in the script must agree. A
9999format on the field with aRealtag backing it will display integers only; the operator cannot enter "12.5" because the format strips the decimal point before the script sees it. Use9999.0or9999.99patterns for floating-point values. -
Migrate carefully from V7. Scripts migrated from WinCC V7 or WinCC Professional typically reference
item.InputValueand trigger on "Change" events. These must be rewritten. A line-by-line find-and-replace is not sufficient — the event anchor and the property semantics both differ.
Related Screen Objects and Pattern Consistency
The same read-on-property, write-on-event pattern applies to other input-capable Unified screen objects:
| Screen Object | Read Property | Write Event |
|---|---|---|
| IO field | ProcessValue |
InputFinished |
| Text field (input mode) | ProcessValue |
InputFinished |
| Slider | ProcessValue |
InputFinished / ValueChanged
|
| Toggle switch | ProcessValue |
InputFinished |
| Date/time picker | ProcessValue |
InputFinished |
Once the IO field pattern is in place, the same scripts transfer to other input objects with only the property/event names changed.
Reference Documentation
- IO field (RT Unified) — TIA Portal V20 documentation
- SIMATIC HMI Unified Comfort Panels — Product support
- TIA Portal Help Cloud — Engineering & Runtime Scripting
Why does item.InputValue.set(...) throw an undefined-reference error in WinCC Unified?
The InputValue property does not exist on IO field screen objects in WinCC Unified; it was a WinCC V7 and WinCC Professional (Comfort) legacy member. In Unified the equivalent write path is item.ProcessValue.set(...) inside an InputFinished event handler, or a direct tag dynamization on the ProcessValue property.
How do I write a value entered in an IO field back to a PLC tag using JavaScript in TIA Portal V20?
Select the IO field, open Properties → Events → Input finished, and add a script that calls Tags("YourTag").Write(value). The runtime passes the operator's entered value as the value argument. Do not place this write call on the ProcessValue property script — that creates a write-back loop that prevents operator input.
The IO field shows the PLC value correctly but rejects operator input. What is wrong?
The write logic is almost certainly bound to the wrong trigger. Confirm that the Tags("Tag101").Write(value) call is inside the InputFinished event handler, not on a cyclic script or on the ProcessValue property. Also verify that the logged-in operator's role includes write authorization for the tag.
Can I read and write the same tag from one IO field in Unified?
Yes. Configure the IO field's Mode as Input/output and bind (or script) the same tag on the ProcessValue property. The read direction is handled automatically each cycle, and the InputFinished event writes the entered value back to the same tag. No separate read/write tags are required.
Is the InputValueChanged event available in WinCC Unified?
No. InputValueChanged was a WinCC V7/Professional event and has no equivalent in Unified. Use InputFinished for one-shot writes after operator confirmation, or use property dynamization on ProcessValue for continuous read behavior. For periodic evaluation of a changing value, use a separate cyclic script on a screen-level timer rather than a per-field event.