<?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: Function to update stream entries in ThingWorx Developers</title>
    <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Function-to-update-stream-entries/m-p/662855#M44719</link>
    <description>&lt;P&gt;You have the service&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;QueryStreamEntriesWithData in order to query the data, and then you can iterate over each previous result and use&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;UpdateStreamEntry&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Apr 2020 06:48:44 GMT</pubDate>
    <dc:creator>CarlesColl</dc:creator>
    <dc:date>2020-04-28T06:48:44Z</dc:date>
    <item>
      <title>Function to update stream entries</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Function-to-update-stream-entries/m-p/662793#M44713</link>
      <description>&lt;P&gt;All..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a stream with data coming in. I'd like to create or use a service to update stream entries.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;End goal would be for the service to have 3 inputs (start,end,tag) so the service would add the "tag" tag to all entries between "start" datetime and "end" datetime.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see the built in "UpdateStreamEntry" so I suppose I could query all stream entries between the two datetimes, and then loop through that entire query result calling&amp;nbsp;UpdateStreamEntry each time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, I'd like to know if there is already a pre-built function to do this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 21:11:36 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Function-to-update-stream-entries/m-p/662793#M44713</guid>
      <dc:creator>a-dub</dc:creator>
      <dc:date>2020-04-27T21:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Function to update stream entries</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Function-to-update-stream-entries/m-p/662855#M44719</link>
      <description>&lt;P&gt;You have the service&amp;nbsp;&lt;SPAN style="font-family: inherit;"&gt;QueryStreamEntriesWithData in order to query the data, and then you can iterate over each previous result and use&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="font-family: inherit;"&gt;UpdateStreamEntry&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 06:48:44 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Function-to-update-stream-entries/m-p/662855#M44719</guid>
      <dc:creator>CarlesColl</dc:creator>
      <dc:date>2020-04-28T06:48:44Z</dc:date>
    </item>
    <item>
      <title>Re: Function to update stream entries</title>
      <link>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Function-to-update-stream-entries/m-p/662948#M44735</link>
      <description>&lt;P&gt;Here is some code I developed for this task (if anyone wants to re-use). You can replace GetStreamEntriesWithData service with&amp;nbsp;&lt;SPAN&gt;QueryStreamEntriesWithData&amp;nbsp;to use like CarlesColl said.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;var table =  me.GetStreamEntriesWithData({
	oldestFirst: true /* BOOLEAN */,
	maxItems: 15 /* NUMBER */
});

var row;
var tableLength = table.rows.length;

for (var x=0; x &amp;lt; tableLength; x++) {
    row = table.rows[x];
    
    row.tags.AddTag("BatchNumbers","D000001");
    
    me.UpdateStreamEntry({
		values: me.CreateValuesWithData({
        	values: {column1: row.column1,
                        column2:  row.column2,
                        column3:  row.column3,
                        column4:  row.column4,
                        column5:  row.column5,
                        column6:  row.column6,
                        column7:  row.column7} /* JSON */
                    }) /* INFOTABLE */,
		streamEntryId: row.id /* STRING */,
		location: row.location /* LOCATION */,
		source: row.source /* STRING */,
		tags: row.tags /* TAGS */
	});
}

var result =  me.GetStreamEntriesWithData({
	oldestFirst: true/* BOOLEAN */,
	maxItems: 20 /* NUMBER */
});&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2020 14:54:49 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/ThingWorx-Developers/Function-to-update-stream-entries/m-p/662948#M44735</guid>
      <dc:creator>a-dub</dc:creator>
      <dc:date>2020-04-28T14:54:49Z</dc:date>
    </item>
  </channel>
</rss>

