<?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 Re: [Help] Get field values dynamically from InfoTable in ThingWorx Developers</title>
    <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Help-Get-field-values-dynamically-from-InfoTable/m-p/620364#M37894</link>
    <description>&lt;P&gt;Hello.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would some of the examples offered in &lt;A href="https://www.ptc.com/en/support/article?n=CS297914" target="_self"&gt;this article about Dynamic Queries&lt;/A&gt; get you started in the right direction? Let me know if this is helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-- Craig A.&lt;/P&gt;</description>
    <pubDate>Mon, 29 Jul 2019 17:16:17 GMT</pubDate>
    <dc:creator>CRArko</dc:creator>
    <dc:date>2019-07-29T17:16:17Z</dc:date>
    <item>
      <title>[Help] Get field values dynamically from InfoTable</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Help-Get-field-values-dynamically-from-InfoTable/m-p/620268#M37870</link>
      <description>&lt;P&gt;Hi there!&lt;/P&gt;
&lt;P&gt;I'm writing a service to convert any InfoTable to CSV text.&lt;/P&gt;
&lt;P&gt;The input is InfoTable without DataShape, it can be any InfoTable, with any filed definition.&lt;/P&gt;
&lt;P&gt;Now to make this service possible, I need to read data from InfoTable rows dynamically.&lt;/P&gt;
&lt;P&gt;Normally, I can use row.FieldName to get field value.&lt;/P&gt;
&lt;P&gt;But in my case, the feild name is a variable, so I want to use some function like row.values[myVariable].&lt;/P&gt;
&lt;P&gt;And I cannot find any possible method to read data as I expected.&lt;/P&gt;
&lt;P&gt;Any advise?&lt;/P&gt;
&lt;P&gt;Thanks a lot!&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 08:52:01 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Help-Get-field-values-dynamically-from-InfoTable/m-p/620268#M37870</guid>
      <dc:creator>tallrain</dc:creator>
      <dc:date>2019-07-29T08:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: [Help] Get field values dynamically from InfoTable</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Help-Get-field-values-dynamically-from-InfoTable/m-p/620364#M37894</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Would some of the examples offered in &lt;A href="https://www.ptc.com/en/support/article?n=CS297914" target="_self"&gt;this article about Dynamic Queries&lt;/A&gt; get you started in the right direction? Let me know if this is helpful.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-- Craig A.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Jul 2019 17:16:17 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Help-Get-field-values-dynamically-from-InfoTable/m-p/620364#M37894</guid>
      <dc:creator>CRArko</dc:creator>
      <dc:date>2019-07-29T17:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: [Help] Get field values dynamically from InfoTable</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Help-Get-field-values-dynamically-from-InfoTable/m-p/620465#M37912</link>
      <description>&lt;P&gt;Thanks for the information, but I cannot access into that article.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I've fixed this issue with below codes :):&lt;/P&gt;
&lt;P&gt;---------------------------------------------------------------------------------------------------------&lt;/P&gt;
&lt;P&gt;var iLF;&lt;BR /&gt;var tmp = 'TIME';&lt;BR /&gt;var i = 0;&lt;BR /&gt;var fd = []; // array to store Fields&lt;BR /&gt;fd[0] = 'TIME';&lt;/P&gt;
&lt;P&gt;// Get CSV Header&lt;BR /&gt;if ((myInfoTable.dataShape===null)||(myInfoTable.dataShape===undefined)) {&lt;BR /&gt;iLF = myInfoTable.ToJSON().dataShape.fieldDefinitions;&lt;BR /&gt;} else {&lt;BR /&gt;iLF = myInfoTable.dataShape.fields;&lt;BR /&gt;}&lt;BR /&gt;for (var key in iLF) {&lt;BR /&gt;if(key != 'TIME') {&lt;BR /&gt;i = i + 1; &lt;BR /&gt;fd[i] = key; // Store field sequence&lt;BR /&gt;tmp = tmp + ',' + key;&lt;BR /&gt;}&lt;BR /&gt;//var result = key;&lt;BR /&gt;//Logger.info("Field Name "+key+" baseType: "+iLF[key].baseType);&lt;BR /&gt;}&lt;BR /&gt;tmp = tmp + ' \n';&lt;BR /&gt;//logger.info('JSON2CSV, i='+i);&lt;/P&gt;
&lt;P&gt;// Get CSV Data&lt;BR /&gt;var tableLength = myInfoTable.rows.length;&lt;BR /&gt;for (var x=0; x &amp;lt; tableLength; x++) {&lt;BR /&gt;var row = myInfoTable.rows[x];&lt;BR /&gt;//logger.info('JSON2CSV, row='+row);&lt;BR /&gt;tmp = tmp + dateFormatISO(row.TIME); // Get TIME Value&lt;/P&gt;
&lt;P&gt;var fd2 = []; // To output data in sequence&lt;BR /&gt;for (var property in row) {&lt;BR /&gt;tmp2 = property; //row property&lt;BR /&gt;//logger.info('JSON2CSV, tmp2='+tmp2);&lt;BR /&gt;tmp3 = row[property]; //row value&lt;BR /&gt;//logger.info('JSON2CSV, tmp3='+tmp3);&lt;BR /&gt;var j = fd.indexOf(tmp2);&lt;BR /&gt;fd2[j] = tmp3;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;for (var k=1; k&amp;lt;fd2.length; k++) {&lt;BR /&gt;tmp = tmp + ',' + fd2[k];&lt;BR /&gt;} &lt;BR /&gt;tmp = tmp + ' \n';&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;var result = tmp;&lt;/P&gt;
&lt;P&gt;---------------------------------------------------------------------------------------------------------&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 02:52:35 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Help-Get-field-values-dynamically-from-InfoTable/m-p/620465#M37912</guid>
      <dc:creator>tallrain</dc:creator>
      <dc:date>2019-07-30T02:52:35Z</dc:date>
    </item>
    <item>
      <title>Re: [Help] Get field values dynamically from InfoTable</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Help-Get-field-values-dynamically-from-InfoTable/m-p/620467#M37913</link>
      <description>&lt;P&gt;I use this service to convert InfoTable into CSV, so that I can display data into Dygraph widget.&lt;/P&gt;
&lt;P&gt;And for Dygraph, the 1st field is always Datatime, so this Service put field of TIME for Time Sequence.&lt;/P&gt;
&lt;P&gt;Now it works just fine.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Jul 2019 02:55:35 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Help-Get-field-values-dynamically-from-InfoTable/m-p/620467#M37913</guid>
      <dc:creator>tallrain</dc:creator>
      <dc:date>2019-07-30T02:55:35Z</dc:date>
    </item>
  </channel>
</rss>

