Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

How to create a subscription for boolean property?


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"; 






Try GetProperties instead, and check the box "Automatically update values when able" that why the connection status will update "automagically" when it connects/disconnects. Also remember to trigger the GetProperties service at Mashup Loaded or alike.




Thanks for your reply Charles,

I have triggered the Mashup Loaded and tried to use GetProperties instead, but no text is shown here as well... 


I also tried to bind the boolean "isConnected" to the label widget instead, which then shows the text "false".
But I want it in this case to be "disconnected", and that is why I created the script using the string ConnectedStatus, which should be bound instead. But when doing so the label is empty

Can it be an error in the script?  


Best regards,



ConnectionStatus changes when isConnected changes? I mean seeing it from the composer? I that's true, then which it's the ValueChange policy on ConnectionStatus it's set to VALUE?

Yes, the purpose is that ConnectionStatus should change, when isConnected changes - but this doesn't happen now...
If I have understood it correct, then yes, the ConnectionStatus' Data Change Type is set to VALUE (see picture below)


Hello @miwhow,


Sorry for a stupid question, but did you enable this subscription? They are disabled by default.


/ Constantine

Yes, I have enabled the subscription - but thanks for the reminder


Top Tags