# Delete is affecting the flow.variables

**URL:** https://discourse.nodered.org/t/delete-is-affecting-the-flow-variables/3539
**Category:** General
**Created:** [28 September 2018 15:09 UTC](https://discourse.nodered.org/t/delete-is-affecting-the-flow-variables/3539 "2018-09-28T15:09:40Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![JoseGodinho](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@JoseGodinho](https://discourse.nodered.org/u/JoseGodinho)
#### Post date: [28 September 2018 15:09 UTC](https://discourse.nodered.org/t/delete-is-affecting-the-flow-variables/3539/1 "2018-09-28T15:09:40Z")

</div>

Hello All

I have this following conundrum

Consider that I have the following flow variable

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/bff391f701bbd507fa008dbef11a01ec4eaa5e92.png)

and the following function node

Tudo =flow.get('firstFloorState');

delete Tudo["temp.guest"];  
delete Tudo["temp.girl"];  
delete Tudo["temp.master"];  
delete Tudo["temp.boy"];  
delete Tudo["temp.sala"];  
delete Tudo["temp.ext"]  
msg.payload=Tudo  
return msg;

now my Flow variables are

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/8677e4e349145983cde5fcfb36c11a2bd60df17d.png)

Should this function without any flow set, alter the variables?

PS:

I am using the V19.2  
Thank you

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [28 September 2018 15:30 UTC](https://discourse.nodered.org/t/delete-is-affecting-the-flow-variables/3539/2 "2018-09-28T15:30:37Z")

</div>

Yes - it isn't ideal, but its how its always worked. The 'get' is returning a reference to the object in memory. The delete operates on that object, so modifies the object in context.

But you have to be careful. If you're using a persistent context, rather than in-memory, if you don't do the 'flow.set' call, the updates to the object will not be saved.

---

<div class="post-metadata">

### Author: ![JoseGodinho](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@JoseGodinho](https://discourse.nodered.org/u/JoseGodinho)
#### Post date: [28 September 2018 15:34 UTC](https://discourse.nodered.org/t/delete-is-affecting-the-flow-variables/3539/3 "2018-09-28T15:34:13Z")

</div>

Understood

Is there another way around way to accomplish the removal of the object?

JLG

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [28 September 2018 15:38 UTC](https://discourse.nodered.org/t/delete-is-affecting-the-flow-variables/3539/4 "2018-09-28T15:38:34Z")

</div>

If you mean you want to retrieve the context value and only pass on certain properties, you can either:

1. clone the context object so you can modify it in place

2. create a new object locally and copy in the values you do want

---

<div class="post-metadata">

### Author: ![JoseGodinho](https://avatars.discourse-cdn.com/v4/letter/j/f4b2a3/32.png) [@JoseGodinho](https://discourse.nodered.org/u/JoseGodinho)
#### Post date: [28 September 2018 15:43 UTC](https://discourse.nodered.org/t/delete-is-affecting-the-flow-variables/3539/5 "2018-09-28T15:43:28Z")

</div>

Thank you!!!
