I need the n historic states of a string-item.
With previousState i get the last value.
But how can I get the prelast, preprelast a.s.o.
Michael
I need the n historic states of a string-item.
With previousState i get the last value.
But how can I get the prelast, preprelast a.s.o.
Michael
Unfortunately there is no easy answer for this that I know of. If your Item persisted fairly regularly you can create a loop to go backwards and call historicState to get that Items state at that time.
If you wanted a specific history you could manually create items for the previous values and then overwrite each one in the change rule:
Number TheItem
Number TheItemPrev
Number TheItemPrev2
Number TheItemPrev3
rule "History"
when Item TheItem changed
then
postUpdate(TheItemPrev3, TheItemPrev2.state)
postUpdate(TheItemPrev2, TheItemPrev.state)
postUpdate(TheItemPrev, previousState)
end
It’s not the most elegant solution but would work.
thank you.
I did it that way until I found the previousState-function…
Thought, this would be better and item-saving.
Now I’m back there.
Michael