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

get StreamEntryId from a stream

Highlighted
Newbie

get StreamEntryId from a stream

Hi All,

I have problem to get the StreamEntryId  of last record inserted into a stream. I'm using AddStreamEntry to add the new record.

Following the list of steps :

1) search information

2) add the information to the stream using the AddStreamEntry

3) If I use QueryStreamEntriesWithData with last timestamp used to add the record (#2) --> no data found

4) If I use GetStreamEntries (oldestfirst=false) an StreamEntryId is returned  but it is not the last inserted (not the one I need)

How can I get the StreamEntryId of the last added record ?

These instructions are all part of the same service inside a loop, and the StreamEntryId is needed to refer the correct record.

BR

Dimitri

2 REPLIES 2
Highlighted

Re: get StreamEntryId from a stream

Hello Dimitri,

You can try using below piece of code with OldestFirst = false and result as NUMBER:-

// result: INFOTABLE

var result1 = Things["NameOfStream"].GetStreamEntriesWithData(params);

//id is the column name to be fetched

var result= result1.rows[0].id;

Hope this helps!

Thanks,

Nidhi

Re: get StreamEntryId from a stream

Hello Dimitri,

AddStreamEntry it's an async process, writes are put on a buffer. Then if you query right on the same script for the added entry you will never find it.

Best Regards,

Carles.

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum!