# Custom function node with auto filled code

**URL:** <https://discourse.nodered.org/t/custom-function-node-with-auto-filled-code/9119>\
**Category:** Developing Nodes\
**Created:** [18 March 2019 12:13 UTC](https://discourse.nodered.org/t/custom-function-node-with-auto-filled-code/9119 "2019-03-18T12:13:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mvidhya86](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mvidhya86](https://discourse.nodered.org/u/mvidhya86)\
**Post date:** [18 March 2019 12:13 UTC](https://discourse.nodered.org/t/custom-function-node-with-auto-filled-code/9119/1 "2019-03-18T12:13:02Z")

</div>

Can i create a custom function node with auto filled code in it ? How do i achieve this?

I would like to drag-drop this custom node, and when i double click, the code(which is pre-configured or pre-defined) has to appear in the Code section

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [18 March 2019 12:25 UTC](https://discourse.nodered.org/t/custom-function-node-with-auto-filled-code/9119/2 "2019-03-18T12:25:01Z")

</div>

you could define a subflow containing just the function node you require ?  
or maybe worth looking at the nodegen project - [https://github.com/node-red/node-red-nodegen](https://github.com/node-red/node-red-nodegen) that can create a custom node from a function node.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [18 March 2019 21:01 UTC](https://discourse.nodered.org/t/custom-function-node-with-auto-filled-code/9119/3 "2019-03-18T21:01:11Z")

</div>

> [@mvidhya86](#):
>
> would like to drag-drop this custom node, and when i double click, the code(which is pre-configured or pre-defined) has to appear in the Code section

Yes, I would say this is possible. Not necessarily easy but certainly possible.

If you check out the v2 branch of uibuilder, you will find that I've implemented a full editor there. That loads code from files into the editor just by selecting from a drop-down. You can then change the code and save it back to file.

So all the basics are there in that node.

I assume though, that you want to do something slightly different. uibuilder edits code for use in a client browser, I'm guessing you want the code to run in Node-RED? So you would need to take your clues from the core function node.

---

<div class="post-metadata">

**Author:** ![mvidhya86](https://avatars.discourse-cdn.com/v4/letter/m/d78d45/32.png) [@mvidhya86](https://discourse.nodered.org/u/mvidhya86)\
**Post date:** [20 March 2019 04:13 UTC](https://discourse.nodered.org/t/custom-function-node-with-auto-filled-code/9119/4 "2019-03-20T04:13:35Z")

</div>

Thanks, will check this
