# Create mapping template node

**URL:** <https://discourse.nodered.org/t/create-mapping-template-node/87452>\
**Category:** Developing Nodes\
**Created:** [24 April 2024 09:00 UTC](https://discourse.nodered.org/t/create-mapping-template-node/87452 "2024-04-24T09:00:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mstoffel-sag](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mstoffel-sag/32/90422_2.png) [@mstoffel-sag](https://discourse.nodered.org/u/mstoffel-sag)\
**Post date:** [24 April 2024 09:00 UTC](https://discourse.nodered.org/t/create-mapping-template-node/87452/1 "2024-04-24T09:00:40Z")

</div>

Hi experts,

I'm quite new to NodeRed development. I try to implement an integration for a Rest API that requires a specific json payload. I would like to create my own node that allows to map certain fields in that json structure. Right now I place a function node in front of the POST request where I map the fields and create the json. This works fine and is very flexible. But I would like to give the user more convenient functions (users dont know the json structure).

It would be great if I could create a node that has already the json fragment as a template and allows the user to map field from msg. of even better from jsonata espression

Any suggestion would be greatly applreciated.

Thanks in advance,

Marco

---

<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:** [24 April 2024 09:05 UTC](https://discourse.nodered.org/t/create-mapping-template-node/87452/2 "2024-04-24T09:05:52Z")

</div>

I have something similar here - not sure if it's close enough - [node-red-contrib-remap (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-remap)

---

<div class="post-metadata">

**Author:** ![kitori](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@kitori](https://discourse.nodered.org/u/kitori)\
**Post date:** [24 April 2024 12:03 UTC](https://discourse.nodered.org/t/create-mapping-template-node/87452/3 "2024-04-24T12:03:10Z")

</div>

Maybe a subflow is the sweet-spot between a function node and dedicated node?

[https://nodered.org/docs/user-guide/editor/workspace/subflows](https://nodered.org/docs/user-guide/editor/workspace/subflows)

You can control the basic input values. In the Subflow, you can request the api and prepare the respond for the users.

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

```auto
[{"id":"e0d28b6139c9b59a","type":"subflow","name":"api","info":"Hi there!\r\nThis is a subflow for the node-red forum.\r\n\r\n`\r\n{\r\n\"payload\": \r\n{\"a\":1,\"b\":2,\"c\":3,\"input_a\":1713959832670,\"input_b\":4,\"input_c\":true}\r\n}\r\n`","category":"","in":[{"x":60,"y":100,"wires":[{"id":"09c8a06e9f8f0332"}]}],"out":[{"x":600,"y":100,"wires":[{"id":"09c8a06e9f8f0332","port":0}]}],"env":[{"name":"input_a","type":"str","value":""},{"name":"input_b","type":"num","value":"","ui":{"type":"spinner","opts":{"min":0,"max":10}}},{"name":"input_c","type":"bool","value":"true","ui":{"type":"checkbox"}}],"meta":{},"color":"#C7E9C0","icon":"font-awesome/fa-magic","status":{"x":600,"y":220,"wires":[{"id":"4d4cfa2fee51f838","port":0}]}},{"id":"09c8a06e9f8f0332","type":"function","z":"e0d28b6139c9b59a","name":"function 3","func":"msg.payload = {\n \"a\" : 1,\n \"b\" : 2,\n \"c\" : 3,\n \"input_a\" : msg.payload.input_a || env.get(\"input_a\"),\n \"input_b\": msg.payload.input_b || env.get(\"input_b\"),\n \"input_c\": msg.payload.input_c || env.get(\"input_c\"),\n}\n\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":240,"y":100,"wires":[["4d4cfa2fee51f838"]]},{"id":"4d4cfa2fee51f838","type":"change","z":"e0d28b6139c9b59a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.input_a","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":220,"wires":[[]]},{"id":"eb7734c464f808a6","type":"subflow:e0d28b6139c9b59a","z":"94c514c2ac360b08","name":"","env":[{"name":"input_b","value":"4","type":"num"}],"x":430,"y":560,"wires":[["4059ea6cdfd75c07"]]},{"id":"9f13857bea64a70f","type":"inject","z":"94c514c2ac360b08","name":"","props":[{"p":"payload.input_a","v":"","vt":"date"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":210,"y":560,"wires":[["eb7734c464f808a6"]]},{"id":"4059ea6cdfd75c07","type":"debug","z":"94c514c2ac360b08","name":"debug 21","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":560,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![mstoffel-sag](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mstoffel-sag/32/90422_2.png) [@mstoffel-sag](https://discourse.nodered.org/u/mstoffel-sag)\
**Post date:** [30 April 2024 09:32 UTC](https://discourse.nodered.org/t/create-mapping-template-node/87452/4 "2024-04-30T09:32:14Z")

</div>

Thanks you very much for your suggestions! I will look into those.

---

<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:** [29 June 2024 09:32 UTC](https://discourse.nodered.org/t/create-mapping-template-node/87452/5 "2024-06-29T09:32:58Z")

</div>

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