...like function nodes, so they remember stuff from one message to the next instead of having to use flow or global storage
I have misread you title. You want the CHANGE node to have a local context, I have read that you want to change nodes to have access to local context Sorry
For clarity could you show an example config you might setup if this could be done?
If it had access to local.last_mytimes instead of flow.last_mytimes then the change node could be copy/pasted at will without having to change the context variable name
[{"id":"1f3433c5.7aae8c","type":"inject","z":"58d3b2b.5686b4c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"something","payloadType":"str","x":100,"y":120,"wires":[["efc72b04.570d78"]]},{"id":"3c65633.fae0a9c","type":"change","z":"58d3b2b.5686b4c","name":"","rules":[{"t":"set","p":"last_mytimes","pt":"msg","to":"last_mytimes","tot":"flow"},{"t":"set","p":"last_mytimes","pt":"flow","to":"mytimes","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":120,"y":240,"wires":[["3f25e048.6ff1b","731acea0.7fb25"]]},{"id":"3f25e048.6ff1b","type":"debug","z":"58d3b2b.5686b4c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"mytimes","statusType":"msg","x":350,"y":240,"wires":[]},{"id":"731acea0.7fb25","type":"debug","z":"58d3b2b.5686b4c","name":"","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"last_mytimes","targetType":"msg","statusVal":"","statusType":"auto","x":390,"y":300,"wires":[]},{"id":"efc72b04.570d78","type":"change","z":"58d3b2b.5686b4c","name":"set msg.mytimes to current hh:mm:ss","rules":[{"t":"set","p":"mytimes","pt":"msg","to":"$moment().format(\"hh:mm:ss\")","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":190,"y":180,"wires":[["3c65633.fae0a9c"]]}]
[edit] $moment expression changed to hh:mm:ss to give correct times [/edit]
I think that this may have come up once or twice in the past.
Personally, I would agree with this request, having a local context for the change node would seem to make sense and would give parity with the function node. Same is true for JSONata as well.
Before we had the context side-bar, this was nice to consider but not terribly practical but it is now perfectly manageable.
Is this only for viewing what is in the change nodes context?
I mean, how would you access it/ get it out - to use it in a later msg?
I can't understand how this would work or what real world situation you could use it for?
Have you looked at my example?
I looked at your screen shot from mobile - I didn't understand.
I've now looked at your flow - still non the wiser.
What is "it" and what is "local"?
The thing I am struggling with...
- In a function node you can get and set context based on some logic
- In a change node - there is no logic - so how does one set a context element & retrieve a context element?
I'm not being funny - I honestly dont understand your intent.
EDIT: ok, so just as i was to walk away - I re-evaluated....
in the screen shot, you to retrieve last_mytimes
from flow then in the next row, its updated from msg.mytimes
- this seems to be about the only use case It may actually work & even then I struggle to see how this can be useful? This is literally something I have never done. Consider this, when you get the value from the change nodes context, it is immediately overwritten by whatever came in the msg. I am struggling to see how adding context to the change node would be worth it for such a singular case?
If I am missing some really useful use-case - please correct me - seriously, do - its like a puzzle I need to solve
Well - I had this use case of wanting to display time of last message and time of the one before.
So as I've done in the past in other flows - I decided to save previous value to flow.context and then I thought - why "pollute" flow context when I only need it inside this change node.
And hence the feature request
But you are right to query how useful this facility will be......
... but.just wait for my follow up switch/trigger node feature request after I've got this one thru the committee
I am (still) strongly in favor of this feature.
There is a helpful discussion at Local Context (revisited) - #6 by drmibell.
The switch node can already compare to previous value...
How/where?
You know, I don't think Simon is the only one who didn't know that existed!
Personally I have no comment to make on this matter.
shows how often people have needed it
One of my idea springs to mind (now that I'm aware of it) would be to have test for a diff between this and previous values.
Then if the node was made super intelligent it could detect time formatted strings and calculate time diff between messages
I think that would help a lot of people out in not having to write JS/JSONata
But this is a completely different feature request so if someone wouldn't mind splitting this thread (I know I prob have the powers but don't know how to do it!)
I have added an item to the backlog for the Change node being able to access context.
https://trello.com/c/EHY8Xc7D/223-change-allow-change-node-to-access-node-level-context
There's not much more to discuss unless someone wants to actual help implement it.
.Creating an alternate install and looking to see how hard its going be!
No 1. Question is going to be - what is it going to be called in the UI ?
local?
node?
context?
[edit]mmm -after spending 2 hours on playing with 15-change.html and red.js- I've got absolutely no-where .... [/edit]
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.