# Can't retrieve a textarea property's value

**URL:** <https://discourse.nodered.org/t/cant-retrieve-a-textarea-propertys-value/27206>\
**Category:** General\
**Created:** [24 May 2020 17:45 UTC](https://discourse.nodered.org/t/cant-retrieve-a-textarea-propertys-value/27206 "2020-05-24T17:45:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jmnobre](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jmnobre](https://discourse.nodered.org/u/jmnobre)\
**Post date:** [24 May 2020 17:45 UTC](https://discourse.nodered.org/t/cant-retrieve-a-textarea-propertys-value/27206/1 "2020-05-24T17:45:39Z")

</div>

Hi,

Looking at similar questions I found only [this one](https://discourse.nodered.org/t/textarea-is-not-holding-the-value/14634), which looks abandoned since August...

So,, summarizing my issue, I am creating a new node... and though using a textarea for one of the properties, and after sometime, decided to search for help.

My environment is

- Node-RED version: v1.0.6
- Node.js version: v8.10.0
- Linux 5.3.0-1022-azure x64 LE

To provide a real example, here is my **package.json** :

```auto
{
  "name": "my-sample-package",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "jmn",
  "license": "ISC",
  "node-red": {
    "nodes": {
      "myexec": "myexec.js"
    }
  }
}

```

The **myexec.html** file is:

```auto
<script type="text/javascript">
  RED.nodes.registerType('myexec',{
    category: 'Learning',
    color: '#008000',
    defaults: {
      name: {value:""},
      command: { value:"" }
    },
    inputs:1,
    outputs:2,
    icon: "function.png",
    label: function() {
      return this.name||"myexec";
    }
  });
</script>

<script type="text/html" data-template-name="myexec">
    <div class="form-row">
      <label for="node-input-name"><i class="icon-tag"></i> Name</label>
      <input type="text" id="node-input-name" placeholder="Name">
    </div>
    <div class="form-row">
      <label for="node-input-command"><i class="icon-tag"></i> Command</label>
      <textarea id="node-input-command" rows="10"></textarea>
    </div>
</script>

<script type="text/html" data-help-name="myexec">
    <p>A simple to execute shell commands</p>
</script>

```

And the **myexec.js** :

```auto
module.exports = function(RED) {
  function Exec(config) {
    RED.nodes.createNode(this,config);
    var node = this;
    node.on('input', function(msg) {
        const { spawn, exec } = require('child_process');
        //const ls = spawn('ls', ['-lh', '/usr']);

        console.log( node )

        const cmd = exec(node.command)

        var m1 = { payload: "", _msgid: msg._msgid }
        var m2 = { payload: "", _msgid: msg._msgid }

        cmd.stdout.on('data', (data) => {
           //m1.payload=String.fromCharCode.apply(null, data)
           //msg.payload = `${data}`
           m1.payload = data.toString()
        });

        cmd.stderr.on('data', (data) => {
           //m2.payload=String.fromCharCode.apply(null, data)
           m2 = { payload: data.toString() }
        });

        cmd.on('close', (code) => {
           console.log(`child process exited with code ${code}`);
        });
        //node.send(msg);
        node.send( [m1, m2] )
      });
    }
    RED.nodes.registerType("myexec",Exec);
}

```

I then created 2 single nodes: an injector and my myexec node:

```auto
[{"id":"eeb01a85.e0abd8","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"199d6185.eed5fe","type":"inject","z":"eeb01a85.e0abd8","name":"","topic":"","payload":"This Is @ TEST!!!!","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":210,"y":160,"wires":[["5acc52df.23e6bc","ac9bbefa.061f"]]},{"id":"dd2d79c6.69ee68","type":"debug","z":"eeb01a85.e0abd8","name":"Out","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":660,"y":140,"wires":[]},{"id":"7144cffd.d395c","type":"debug","z":"eeb01a85.e0abd8","name":"Err","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":640,"y":240,"wires":[]},{"id":"5acc52df.23e6bc","type":"debug","z":"eeb01a85.e0abd8","name":"Inp","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":400,"y":300,"wires":[]},{"id":"ac9bbefa.061f","type":"myexec","z":"eeb01a85.e0abd8","name":"Test","command":"ls /usr -l","x":450,"y":200,"wires":[["dd2d79c6.69ee68"],["7144cffd.d395c"]]}]

```

When I trigger a time event, I see the following on the console:

```auto
24 May 17:42:14 - [info] Server now running at http://127.0.0.1:1880/
Exec {
  id: 'ac9bbefa.061f',
  type: 'myexec',
  z: 'eeb01a85.e0abd8',
  _closeCallbacks: [],
  _inputCallback: [Function],
  _inputCallbacks: null,
  name: 'Test',
  _asyncDelivery: true,
  wires: [[ 'dd2d79c6.69ee68'], ['7144cffd.d395c'] ],
  _wireCount: 2,
  send: [Function] }
24 May 17:44:12 - [error] [myexec:Test] TypeError: "file" argument must be a non-empty string

```

I was expecting to see the _command_ property, but it is nowhere to be seen...  
Any idea?

Thanks in advance  
José

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 May 2020 18:01 UTC](https://discourse.nodered.org/t/cant-retrieve-a-textarea-propertys-value/27206/2 "2020-05-24T18:01:39Z")

</div>

Not sure it textarea is supported. Try a regular hidden input (like in many of the core nodes on GitHub) and use the onedit and onsave events (can't remember exact event names again, see core nodes) - to populate/save users input on the textarea to/from the hidden field.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [24 May 2020 18:30 UTC](https://discourse.nodered.org/t/cant-retrieve-a-textarea-propertys-value/27206/3 "2020-05-24T18:30:50Z")

</div>

> [@Steve-Mcl](#):
>
> Not sure it textarea is supported.

Hey Steve,  
I have used a textarea for the first time last week, so I expect it to work...

> [@jmnobre](#):
>
> I was expecting to see the _command_ property

Hi José,  
I haven't tried your code yet, but could it be that you have forgotten to copy the command (from the node config to the node instance itself)? I think you should add an extra line:

```auto
  function Exec(config) {
    RED.nodes.createNode(this,config);
    this.command = config.command;
    var node = this;

```

Bart

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 May 2020 18:32 UTC](https://discourse.nodered.org/t/cant-retrieve-a-textarea-propertys-value/27206/4 "2020-05-24T18:32:24Z")

</div>

Ah well spotted Bart.

---

<div class="post-metadata">

**Author:** ![jmnobre](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@jmnobre](https://discourse.nodered.org/u/jmnobre)\
**Post date:** [24 May 2020 21:25 UTC](https://discourse.nodered.org/t/cant-retrieve-a-textarea-propertys-value/27206/5 "2020-05-24T21:25:57Z")

</div>

Thanks Bart,  
It was definitely the problem 🙂 Got it working!

---

<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:** [7 June 2020 21:25 UTC](https://discourse.nodered.org/t/cant-retrieve-a-textarea-propertys-value/27206/6 "2020-06-07T21:25:58Z")

</div>

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