<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to create a subscription for boolean property? in ThingWorx Developers</title>
    <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/661799#M44559</link>
    <description>&lt;P&gt;Hi all&lt;/P&gt;
&lt;P&gt;I am new in javascript coding and hope some of you can help me in proceeding with my problem.&lt;/P&gt;
&lt;P&gt;I am using ThingWorx 8.3.7.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want a label-widget to be displayed with either the text "&lt;EM&gt;Connected&lt;/EM&gt;" or "&lt;EM&gt;Disconnected&lt;/EM&gt;" on my dashboard to show if the machine is connected or not.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working with two properties:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Boolean: &lt;STRONG&gt;isConnected&lt;/STRONG&gt;
&lt;UL&gt;
&lt;LI&gt;when boolean is true: the text should be "Connected"&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;when boolean is false: the text should be "Disconnected"&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;UL&gt;
&lt;LI&gt;String: &lt;STRONG&gt;ConnectionStatus&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if you need further information &lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thanks, Michelle&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;if(eventData.newValue.value === true) { 
    me.ConnectionStatus = "Connected";
} else { 
    me.ConnectionStatus = "Disonnected"; 
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Subscription.JPG" style="width: 999px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/26121i9D435A9CE13EDB8E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Subscription.JPG" alt="Subscription.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Binding.JPG" style="width: 543px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/26120i5A34B7F9E01B1BAF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Binding.JPG" alt="Binding.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 23 Apr 2020 11:24:35 GMT</pubDate>
    <dc:creator>miwhow</dc:creator>
    <dc:date>2020-04-23T11:24:35Z</dc:date>
    <item>
      <title>How to create a subscription for boolean property?</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/661799#M44559</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;
&lt;P&gt;I am new in javascript coding and hope some of you can help me in proceeding with my problem.&lt;/P&gt;
&lt;P&gt;I am using ThingWorx 8.3.7.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want a label-widget to be displayed with either the text "&lt;EM&gt;Connected&lt;/EM&gt;" or "&lt;EM&gt;Disconnected&lt;/EM&gt;" on my dashboard to show if the machine is connected or not.&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am working with two properties:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Boolean: &lt;STRONG&gt;isConnected&lt;/STRONG&gt;
&lt;UL&gt;
&lt;LI&gt;when boolean is true: the text should be "Connected"&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;when boolean is false: the text should be "Disconnected"&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;UL&gt;
&lt;LI&gt;String: &lt;STRONG&gt;ConnectionStatus&lt;/STRONG&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please let me know if you need further information &lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thanks, Michelle&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;if(eventData.newValue.value === true) { 
    me.ConnectionStatus = "Connected";
} else { 
    me.ConnectionStatus = "Disonnected"; 
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Subscription.JPG" style="width: 999px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/26121i9D435A9CE13EDB8E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Subscription.JPG" alt="Subscription.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Binding.JPG" style="width: 543px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/26120i5A34B7F9E01B1BAF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Binding.JPG" alt="Binding.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 11:24:35 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/661799#M44559</guid>
      <dc:creator>miwhow</dc:creator>
      <dc:date>2020-04-23T11:24:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a subscription for boolean property?</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/661964#M44569</link>
      <description>&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Carles.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Apr 2020 06:51:56 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/661964#M44569</guid>
      <dc:creator>CarlesColl</dc:creator>
      <dc:date>2020-04-23T06:51:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a subscription for boolean property?</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/662581#M44656</link>
      <description>&lt;P&gt;Thanks for your reply Charles,&lt;/P&gt;
&lt;P&gt;I have triggered the Mashup Loaded and tried to use GetProperties instead, but no text is shown here as well...&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also tried to bind the boolean "&lt;STRONG&gt;isConnected&lt;/STRONG&gt;" to the label widget instead, which then shows the text "&lt;EM&gt;false". &lt;BR /&gt;&lt;/EM&gt;But I want it in this case to be "&lt;EM&gt;disconnected&lt;/EM&gt;", and that is why I created the script using the string&amp;nbsp;&lt;STRONG&gt;ConnectedStatus&lt;/STRONG&gt;, which should be bound instead. But when doing so the label is empty&lt;/P&gt;
&lt;P&gt;Can it be an error in the script?&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Michelle&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 06:50:55 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/662581#M44656</guid>
      <dc:creator>miwhow</dc:creator>
      <dc:date>2020-04-27T06:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a subscription for boolean property?</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/662590#M44657</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;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?&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 07:55:19 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/662590#M44657</guid>
      <dc:creator>CarlesColl</dc:creator>
      <dc:date>2020-04-27T07:55:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a subscription for boolean property?</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/662626#M44669</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/313781"&gt;@miwhow&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sorry for a stupid question, but did you &lt;EM&gt;enable&lt;/EM&gt; this subscription? They are disabled by default.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;/ Constantine&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 10:13:21 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/662626#M44669</guid>
      <dc:creator>Constantine</dc:creator>
      <dc:date>2020-04-27T10:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a subscription for boolean property?</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/662633#M44673</link>
      <description>&lt;P&gt;Yes, the purpose is that ConnectionStatus should change, when isConnected changes - but this doesn't happen now...&lt;BR /&gt;If I have understood it correct, then yes, the ConnectionStatus' Data Change Type is set to VALUE (see picture below)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="ConnectionStatus_Value.JPG" style="width: 400px;"&gt;&lt;img src="https://www.ptcusercommunity.com/t5/image/serverpage/image-id/26287iDD771B59B9DD23AD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ConnectionStatus_Value.JPG" alt="ConnectionStatus_Value.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 11:19:04 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/662633#M44673</guid>
      <dc:creator>miwhow</dc:creator>
      <dc:date>2020-04-27T11:19:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a subscription for boolean property?</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/662634#M44674</link>
      <description>&lt;P&gt;Yes, I have enabled the subscription - but thanks for the reminder &lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/P&gt;
&lt;P&gt;/Michelle&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 11:20:14 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/How-to-create-a-subscription-for-boolean-property/m-p/662634#M44674</guid>
      <dc:creator>miwhow</dc:creator>
      <dc:date>2020-04-27T11:20:14Z</dc:date>
    </item>
  </channel>
</rss>

