# How to reset the context store variable

**URL:** <https://discourse.nodered.org/t/how-to-reset-the-context-store-variable/66160>\
**Category:** General\
**Created:** [8 August 2022 07:02 UTC](https://discourse.nodered.org/t/how-to-reset-the-context-store-variable/66160 "2022-08-08T07:02:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ganesh](https://avatars.discourse-cdn.com/v4/letter/g/f19dbf/32.png) [@Ganesh](https://discourse.nodered.org/u/Ganesh)\
**Post date:** [8 August 2022 07:02 UTC](https://discourse.nodered.org/t/how-to-reset-the-context-store-variable/66160/1 "2022-08-08T07:02:40Z")

</div>

Hi  
I am using context variable to store the two values in an flow that i am able to store it ,  
i need help in how reset the data stored in context variable  
I Have Attached my flow below

```auto
[{"id":"aa4e304feff52ade","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"b729f09bd2d6ebe8","type":"debug","z":"aa4e304feff52ade","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":620,"y":140,"wires":[]},{"id":"cac01e08e6b2795d","type":"inject","z":"aa4e304feff52ade","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"ohm114\"]","payloadType":"json","x":200,"y":140,"wires":[["301be4b76ba7e422"]]},{"id":"301be4b76ba7e422","type":"function","z":"aa4e304feff52ade","name":"Store and foward","func":"let store = context.get('store') || {}\n\nObject.assign (store, msg.payload)\n\ncontext.set('store', store); \n\nmsg.payload = store;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":140,"wires":[["b729f09bd2d6ebe8"]]},{"id":"ca79c7ca4a9c4e5b","type":"inject","z":"aa4e304feff52ade","name":"","props":[{"p":"payload.id","v":"[\"axc123\"]","vt":"json"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":210,"y":200,"wires":[["301be4b76ba7e422"]]}]

```

Thank you

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [8 August 2022 07:23 UTC](https://discourse.nodered.org/t/how-to-reset-the-context-store-variable/66160/2 "2022-08-08T07:23:48Z")

</div>

you can use `delete store` to reset full store or `delete store.id` to reset id, or `context.set("store", undefined)` to reset the full store, or `context.set("store.id", undefined)` to reset id.  
e.g.

```auto
[{"id":"cac01e08e6b2795d","type":"inject","z":"aa4e304feff52ade","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[\"ohm114\"]","payloadType":"json","x":200,"y":140,"wires":[["301be4b76ba7e422"]]},{"id":"301be4b76ba7e422","type":"function","z":"aa4e304feff52ade","name":"Store and foward","func":"let store = context.get('store') || {}\nif(msg.delete){\n delete store[msg.delete];\n}else{\nObject.assign (store, msg.payload)\n}\ncontext.set('store', store); \n\nmsg.payload = store;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":140,"wires":[["b729f09bd2d6ebe8"]]},{"id":"ca79c7ca4a9c4e5b","type":"inject","z":"aa4e304feff52ade","name":"","props":[{"p":"payload.id","v":"[\"axc123\"]","vt":"json"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":190,"y":180,"wires":[["301be4b76ba7e422"]]},{"id":"b17d678a.cb8418","type":"inject","z":"aa4e304feff52ade","name":"delete id","props":[{"p":"delete","v":"id","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":190,"y":260,"wires":[["301be4b76ba7e422"]]},{"id":"bfe9d959.0f4958","type":"inject","z":"aa4e304feff52ade","name":"delete 0","props":[{"p":"delete","v":"0","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":200,"y":300,"wires":[["301be4b76ba7e422"]]},{"id":"b729f09bd2d6ebe8","type":"debug","z":"aa4e304feff52ade","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":620,"y":140,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 August 2022 07:23 UTC](https://discourse.nodered.org/t/how-to-reset-the-context-store-variable/66160/3 "2022-08-22T07:23:48Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
