Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X
All..
I have a stream with data coming in. I'd like to create or use a service to update stream entries.
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.
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 UpdateStreamEntry each time.
However, I'd like to know if there is already a pre-built function to do this?
Thanks
Solved! Go to Solution.
You have the service QueryStreamEntriesWithData in order to query the data, and then you can iterate over each previous result and use UpdateStreamEntry
You have the service QueryStreamEntriesWithData in order to query the data, and then you can iterate over each previous result and use UpdateStreamEntry
Here is some code I developed for this task (if anyone wants to re-use). You can replace GetStreamEntriesWithData service with QueryStreamEntriesWithData to use like CarlesColl said.
var table = me.GetStreamEntriesWithData({
oldestFirst: true /* BOOLEAN */,
maxItems: 15 /* NUMBER */
});
var row;
var tableLength = table.rows.length;
for (var x=0; x < 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 */
});