I am using nodeState.putShared(“counter”, 1) in first scripted node and in second scripted node I get the value and increment it and put it back in nodeState.putShared(“counter”, 2).
However, I am expecting the last value set that is 2 when i do nodeState.get(“counter”) in any subsequent node but I get the initial value that is 1.
Tried to remove the variable from nodeState.remove(“counter”) but still does not help, it returns the first value set.
How to override/update the value set in nodeState.putShared() ?
FYI: IDCloud is to deprecate the bindings sharedState and transientState per OPENAM-17666.
Also, I would suggest printing out the value to logs to inspect what is going on. I do expect the counter to be updated. Also, please note, the get(key) method retrieves the state for the key from the NodeState in the following order: transient, secure, shared. So, if you have the same key in the transient state, the method returns the value from the transient state first.
Unfortunately, this looks like a bug. I also expected the counter would be updated, but using t.he putShared method seems to only work if the key is not already set
Due to too much dependencies and already customization written, it is hard to fix w/o bounding the unknown impact of all enduser scripts. So in due cause the solution is to move slowly away from this deprecate usage.