How to create a subscription for boolean property?
Hi all
I am new in javascript coding and hope some of you can help me in proceeding with my problem.
I am using ThingWorx 8.3.7.
I want a label-widget to be displayed with either the text "Connected" or "Disconnected" on my dashboard to show if the machine is connected or not.
I am working with two properties:
- Boolean: isConnected
- when boolean is true: the text should be "Connected"
- when boolean is false: the text should be "Disconnected"
- String: ConnectionStatus
I have tried to create a simple subscription (see script and picture below) with the if/else statement, but when the mashup is loaded the label is not visible with any of the texts. I used the GetPropertyValue service and bound the ConnectionStatus string to the label-widget.
Am I missing anything or writing the script/statements wrong? (eg the booleans false/true value) Or is there a better way to achieve this?
Please let me know if you need further information 🙂
Thanks, Michelle
if(eventData.newValue.value === true) {
me.ConnectionStatus = "Connected";
} else {
me.ConnectionStatus = "Disonnected";
}
