# How to create an empty context object

**URL:** <https://discourse.nodered.org/t/how-to-create-an-empty-context-object/82355>\
**Category:** General\
**Created:** [26 October 2023 10:01 UTC](https://discourse.nodered.org/t/how-to-create-an-empty-context-object/82355 "2023-10-26T10:01:23Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [26 October 2023 13:19 UTC](https://discourse.nodered.org/t/how-to-create-an-empty-context-object/82355/21 "2023-10-26T13:19:04Z")

</div>

It may have been nearly understandable but it was wrong!

This is the one that works properly 🙂

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/a/0a996c61278f249c14013ee84a92cc2b1b7f0482.png)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [26 October 2023 13:30 UTC](https://discourse.nodered.org/t/how-to-create-an-empty-context-object/82355/22 "2023-10-26T13:30:25Z")

</div>

And of course, doesn't work in my real flow! ☹  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/0/80926311fb21c2507e68eda8dd99d9350f607236.png)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/0/30f9bb457f31608d4db70bbf0c8bebb8fce78a8c.png)

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [26 October 2023 13:37 UTC](https://discourse.nodered.org/t/how-to-create-an-empty-context-object/82355/23 "2023-10-26T13:37:43Z")

</div>

Simon, you don't need the "$not", just swap both sides of the ":" operator.  
$flowContext("homemadeSub") : {}

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [26 October 2023 13:42 UTC](https://discourse.nodered.org/t/how-to-create-an-empty-context-object/82355/24 "2023-10-26T13:42:32Z")

</div>

Of course I don't - I stuck it in my original faulty version

it's still not working in my real flow though ☹

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/3/632ec2dda44279d5ba859c7249cf6a6b9d84e6ea.png)

---

<div class="post-metadata">

**Author:** ![ghayne](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ghayne/32/39_2.png) [@ghayne](https://discourse.nodered.org/u/ghayne)\
**Post date:** [26 October 2023 13:47 UTC](https://discourse.nodered.org/t/how-to-create-an-empty-context-object/82355/25 "2023-10-26T13:47:56Z")

</div>

Works for me:

```auto
[{"id":"3280794c.eb6396","type":"change","z":"9a769d3cc79cd9e4","name":"","rules":[{"t":"set","p":"homemadeSub","pt":"flow","to":"$exists($flowContext(\"homemadeSub\")) ? $flowContext(\"homemadeSub\") : {}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":100,"wires":[["10a54176.da8daf"]]}]

```

![Screenshot_2023-10-26_14-48-40](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/e/aec15c64e3549f6009e57bfe380b5abe8b5f8247.png)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [26 October 2023 13:55 UTC](https://discourse.nodered.org/t/how-to-create-an-empty-context-object/82355/26 "2023-10-26T13:55:16Z")

</div>

And of course, yours works for me as well 🙂

When I'm really bored - I'll try and work out what the difference is between yours and mine 🙂

```auto
[{"id":"bd75de939b96d814","type":"change","z":"f7546f055375d300","name":"BROKEN","rules":[{"t":"set","p":"homemadeSub","pt":"flow","to":"$exists($flowContext(\"homemadeSub\")) ? $flowContex(\"homemadeSub\") : {}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":760,"y":760,"wires":[["10a54176.da8daf"]]},{"id":"ab01324c.4824","type":"inject","z":"f7546f055375d300","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":540,"y":760,"wires":[["bd75de939b96d814"]]},{"id":"10a54176.da8daf","type":"debug","z":"f7546f055375d300","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":950,"y":760,"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:** [9 November 2023 13:56 UTC](https://discourse.nodered.org/t/how-to-create-an-empty-context-object/82355/27 "2023-11-09T13:56:16Z")

</div>

Closed on 9 November 2023 13:56 UTC

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

[Previous page](https://discourse.nodered.org/t/how-to-create-an-empty-context-object/82355.md?page=1)
