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

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

get StreamEntryId from a stream

dbologna1
1-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
nbansal
12-Amethyst
(To:dbologna1)

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

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.

Top Tags