# Cannot set property 'text' of undefined"

**URL:** https://discuss.elastic.co/t/cannot-set-property-text-of-undefined/115791
**Category:** Elasticsearch
**Created:** [January 16, 2018, 9:45pm UTC](https://discuss.elastic.co/t/cannot-set-property-text-of-undefined/115791 "2018-01-16T21:45:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ericschlichting](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ericschlichting/32/26644_2.png) [@ericschlichting](https://discuss.elastic.co/u/ericschlichting)
#### Post date: [January 16, 2018, 9:45pm UTC](https://discuss.elastic.co/t/cannot-set-property-text-of-undefined/115791/1 "2018-01-16T21:45:09Z")

</div>

Ran into an issue where I couldn't set up an email action on a watch in Kibana 6.1.1 and was getting this error in the kibana log:

"error":{"message":"Uncaught error: Cannot set property 'text' of undefined","name":"TypeError","stack":"TypeError: Uncaught error: Cannot set property 'text' of undefined\n at EmailAction.get upstreamJson [as upstreamJson] (D:/Program Files/Kibana/kibana-6.1.1/plugins/x-pack/plugins/watcher/server/models/action/email\_action.js:48:7)\n at action (D:/Program Files/Kibana/kibana-6.1.1/plugins/x-pack/plugins/watcher/server/models/watch/threshold\_watch/build\_actions.js:10:27)\n at arrayEach (D:\Program Files\Kibana\kibana-6.1.1\plugins\x-pack\node\_modules\lodash\index.js:1289:13)\n at D:\Program Files\Kibana\kibana-6.1.1\plugins\x-pack\node\_modules\lodash\index.js:3345:13\n at buildActions (D:/Program Files/Kibana/kibana-6.1.1/plugins/x-pack/plugins/watcher/server/models/watch/threshold\_watch/build\_actions.js:9:3)\n at ThresholdWatch.get watchJson [as watchJson] (D:/Program Files/Kibana/kibana-6.1.1/plugins/x-pack/plugins/watcher/server/models/watch/threshold\_watch/threshold\_watch.js:51:18)\n at handler (D:/Program Files/Kibana/kibana-6.1.1/plugins/x-pack/plugins/watcher/server/routes/api/watch/register\_execute\_route.js:31:73)\n at Object.internals.handler (D:\Program Files\Kibana\kibana-6.1.1\node\_modules\hapi\lib\handler.js:96:36)\n at Items.serial (D:\Program Files\Kibana\kibana-6.1.1\node\_modules\hapi\lib\handler.js:63:26)\n at done (D:\Program Files\Kibana\kibana-6.1.1\node\_modules\hapi\node\_modules\items\lib\index.js:31:25)\n at done (D:\Program Files\Kibana\kibana-6.1.1\node\_modules\hapi\node\_modules\items\lib\index.js:63:25)\n at pre (D:\Program Files\Kibana\kibana-6.1.1\node\_modules\hapi\lib\handler.js:52:24)\n at finalize (D:\Program Files\Kibana\kibana-6.1.1\node\_modules\hapi\lib\handler.js:281:20)\n at wrapped (D:\Program Files\Kibana\kibana-6.1.1\node\_modules\hoek\lib\index.js:875:20)\n at internals.Response.\_processPrepare (D:\Program Files\Kibana\kibana-6.1.1\node\_modules\hapi\lib\response.js:521:16)\n at internals.Response.\_prepare (D:\Program Files\Kibana\kibana-6.1.1\node\_modules\hapi\lib\response.js:460:21)\n at process.nextTick (D:\Program Files\Kibana\kibana-6.1.1\node\_modules\hapi\lib\reply.js:152:22)\n at \_combinedTickCallback (internal/process/next\_tick.js:73:7)\n at process.\_tickDomainCallback (internal/process/next\_tick.js:128:9)"},"url":{"protocol":null,"slashes":null,"auth":null,"host":null,"port":null,"hostname":null,"hash":null,"search":"","query":{},"pathname":"/api/watcher/watch/execute","path":"/api/watcher/watch/execute","href":"/api/watcher/watch/execute"},"message":"Uncaught error: Cannot set property 'text' of undefined"}  
{"type":"response","@timestamp":"2018-01-16T20:53:43Z","tags":[],"pid":1640,"method":"put","statusCode":500,"req":{"url":"/api/watcher/watch/execute","method":"put","headers":{"host":"host:5601","connection":"keep-alive","content-length":"692","accept":"application/json, text/plain, _/_","origin":"[http://host:5601](http://host:5601)","kbn-version":"6.1.1","user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36","content-type":"application/json;charset=UTF-8","referer":"[http://host:5601/app/kibana","accept-encoding":"gzip](http://host:5601/app/kibana%22,%22accept-encoding%22:%22gzip), deflate","accept-language":"en-US,en;q=0.9"},"remoteAddress":"10.2.100.175","userAgent":"10.2.100.175","referer":"[http://host:5601/app/kibana"},"res":{"statusCode":500,"responseTime":40,"contentLength":9},"message":"PUT](http://host:5601/app/kibana%22%7D,%22res%22:%7B%22statusCode%22:500,%22responseTime%22:40,%22contentLength%22:9%7D,%22message%22:%22PUT) /api/watcher/watch/execute 500 40ms - 9.0B"}

Looks like this might be fixed by changing line 48 of email\_action.js from:  
optionalFields.body.text = this.body;  
to:  
optionalFields.body = this.body;

and line 78 from:  
optionalFields.body = json.actionJson.email.body.text;  
to:  
optionalFields.body = json.actionJson.email.body;

🙂

---

<div class="post-metadata">

### Author: ![ericschlichting](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ericschlichting/32/26644_2.png) [@ericschlichting](https://discuss.elastic.co/u/ericschlichting)
#### Post date: [January 17, 2018, 1:55pm UTC](https://discuss.elastic.co/t/cannot-set-property-text-of-undefined/115791/2 "2018-01-17T13:55:51Z")

</div>

Apparently this was fixed in 6.1.2. Thanks!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [February 14, 2018, 1:56pm UTC](https://discuss.elastic.co/t/cannot-set-property-text-of-undefined/115791/3 "2018-02-14T13:56:08Z")

</div>

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