Troubleshooting
Why a WinCC faceplate button color ignores PLC tag changes
Short answer
The background-color assignments sit inside the click-event VBScript, so they run only when the button is clicked; a PLC-side change never triggers them. Bind the button background color to a tag-driven dynamic on the external Boolean and keep the click event only for the read-invert-write. Also drop Set on SmartTags: it copies a tag object reference, not the Boolean value.

On this page
The color assignment sits inside the click-event VBScript, so it runs only when the button is clicked; a Boolean changed in the PLC data block never triggers it. Separate the command from the indication: keep the click event for the read-invert-write of the tag, and bind the button background color to a tag-driven dynamic on the external Boolean, for example gray for False and yellow for True. Fix the Set misuse as well, because Set on SmartTags copies a tag object reference instead of the Boolean value.
Confirm the tag before touching the script #
An external HMI tag connects the runtime to a PLC variable; an internal tag stores its value inside the HMI only. The indication must read the external Boolean that changes in the PLC data block, so check that the tag used by the faceplate instance points at that variable and has a Boolean-compatible data type.
- Open the HMI tag table and confirm the tag's connection, data block address and data type.
- Put a temporary status object on a test screen, bound to the same tag, outside any script.
- Change the Boolean from the PLC side through an authorized test operation and watch the status object follow both states.
- If the status object does not move, resolve the connection and acquisition settings before going further; a color script cannot fix a wrong address or a dead connection.
This check also catches the faceplate trap: each instance carries its own interface binding, so a similarly named internal tag or the wrong instance connection can make a local click appear successful while showing nothing about the real process state.
Fix the value access in the click script #
The script mixes an object reference with Boolean logic. In VBScript, Set assigns an object reference, so after Set mytag = SmartTags("TagName") the variable holds the SmartTag object, not the Boolean; the If test and the inversion then do not behave as value logic. Use ordinary assignment:
Dim mytag
mytag = SmartTags("TagName")
If mytag Then
mytag = False
Else
mytag = True
End If
SmartTags("TagName") = mytag
Replace TagName with the configured tag name of the instance. On the left side of an assignment, SmartTags("TagName") is the destination and the value on the right is what gets written; reading is the same expression on the right side. The WinCC engineering reference documents the SmartTags list as returning a SmartTag object for the named tag, which is exactly the object you do not want in a plain Boolean variable.
The object-based route is different: with Set tagObject = HMIRuntime.Tags("TagName") the Set is correct because tagObject holds a Tag object, and the object's Write method performs the assignment, for example tagObject.Write True. The WinCC V7 scripting reference describes the Tags list as the runtime access to tag properties and methods. If you want the trade-offs of the two access routes side by side, the comparison of HMIRuntime.Tags versus SmartTags in WinCC TIA Portal covers when each one fits.
After the fix, click the button once on the bench: the PLC Boolean must change state and stay there unless the PLC logic itself moves it.
Move the color into a tag-driven dynamic #
An event script executes when its event fires and nothing else. The If statement in the click handler evaluated mytag once, at click time; it never created a subscription. That is why the button updates on click but ignores a data-block change made from the PLC side.
A property dynamic is the runtime mechanism that does follow a tag. The WinCC working documentation shows the path for a button property: open the property's pop-up menu and create a dynamic dialog with a tag as the trigger, which reevaluates the background color whenever the tag changes. Configure it like this:
- Bind the background color dynamic to the external Boolean tag, not to a script variable.
- Map False to gray, RGB(192,192,192), and True to yellow, RGB(255,255,0), matching the colors the original script used.
- Delete the background-color assignments from the click script so exactly one mechanism owns the displayed color.
- If the configuration instead uses a scripted property action, return the color from the structure the editor generates; do not paste an event handler into a property action.
For a boolean tag, that dynamic refreshes with the tag's acquisition cycle. At a typical 100 ms acquisition and a cyclic-continuous update mode, a PLC-side change appears on the button within a fraction of a second after acquisition picks it up; if the tag is set to acquire on use only, the update still fires on the change because the dynamic references the tag continuously. The exact delay you see is acquisition cycle plus screen update, so measure it on the bench rather than trusting a nominal figure.
Check the faceplate instance and competing writers #
Because a faceplate is reused, verify that the command and the indication resolve to the same signal in every instance. Prefer the faceplate interface binding over a hard-coded external tag name in the script. The expression ScreenItems("Button_1") also resolves only within the script's own object context: success from a button event does not prove that another faceplate context or a screen-level action resolves the same object, and the property dynamic avoids that lookup entirely.
| Observed behavior | What to check | Expected result |
|---|---|---|
| One instance works, another does not | Instance interface connections | Each instance points at its own Boolean |
| Color changes on click, then reverts | Another animation or script writing the background | One mechanism owns the color |
| Color updates only after clicking | Color dynamic trigger | Tag change alone reevaluates the color |
| PLC value snaps back after a command | PLC assignments to the variable | PLC logic matches the command design |
Change one process Boolean with two instances on screen: only the corresponding button must change.
Acceptance test on the bench #
Run the sequence with the PLC Boolean as the driver and the button untouched by the operator:
- Open the screen with the Boolean at False. The independent status object reads False and the button is gray without any click.
- Set the Boolean True from the PLC side. The status object reads True and the button turns yellow after acquisition and dynamic evaluation.
- Return it to False. The button returns to gray the same way.
- Click the button once. The read-invert-write changes the PLC Boolean and the color follows through the dynamic, not through the script.
One caution on the command itself: a read-invert-write is not atomic. If another HMI client or the PLC can write the same Boolean between your read and your write, the last writer wins; put the toggle logic in the PLC with a one-shot command bit when multiple writers exist. And if the terminal itself is aging beyond what a script fix can save, an industrial panel PC is the fallback when the repair is not worth it.
Questions asked
Why does Set mytag = SmartTags("TagName") break the Boolean test?
In VBScript, Set assigns an object reference. After that line, mytag holds the SmartTag object, not the Boolean value, so an If mytag test and a mytag = False assignment do not behave as value logic and the inversion can silently do the wrong thing. Use plain assignment, mytag = SmartTags("TagName"), and reserve Set for tag objects such as HMIRuntime.Tags, where the Tag object methods do the reading and writing.
Does SmartTags("TagName") = True read the tag or write it?
It writes. On the left side of an assignment, SmartTags("TagName") is the destination, and True is the value being written to that HMI tag, which then travels to the linked PLC variable. Reading is the same expression used on the right side of an assignment, for example mytag = SmartTags("TagName"). There is no separate read or write method needed for SmartTags access.
Can the click script update the color if the PLC changes the tag later?
No. An event script runs only when its event fires, which for a click event means an operator action. Nothing in the script re-runs when the underlying tag changes. The only runtime mechanism that follows a tag continuously is a property dynamic or scripted property action with its own trigger, which is why the indication should live there and the click event should keep only the command.
Why does one faceplate instance update and another not?
Each faceplate instance carries its own interface connections, so two instances can point at different Booleans or at different tags with similar names. Open the instance properties and confirm which external tag each instance binds, then change one PLC Boolean and check that only the matching button changes color. A fixed tag name pasted into every instance defeats the reuse and hides this mismatch.


