# Getting empty value in script field in Kibana 5.2.1

**URL:** <https://discuss.elastic.co/t/getting-empty-value-in-script-field-in-kibana-5-2-1/104306>\
**Category:** Kibana\
**Created:** [October 17, 2017, 9:07pm UTC](https://discuss.elastic.co/t/getting-empty-value-in-script-field-in-kibana-5-2-1/104306 "2017-10-17T21:07:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajkamalkool6](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@rajkamalkool6](https://discuss.elastic.co/u/rajkamalkool6)\
**Post date:** [October 17, 2017, 9:07pm UTC](https://discuss.elastic.co/t/getting-empty-value-in-script-field-in-kibana-5-2-1/104306/1 "2017-10-17T21:07:03Z")

</div>

Hi,

I am using Kibana 5.2.1 scripted field. I wrote one painless script as follows but I am not getting the return value on the created script field. Always I am getting empty value in my script field. I am not sure where I am going wrong.

```
if (doc['msg_sent.keyword'].value == "1" ){ 
   return "Very Dissatisfied";
}
if (doc['user_msg_sent.keyword'].value == "2" ){ 
    return "Dissatisfied";
}

```

Any help is highly appreciable. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![LeeDr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leedr/32/9289_2.png) [@LeeDr](https://discuss.elastic.co/u/LeeDr)\
**Post date:** [October 20, 2017, 7:24am UTC](https://discuss.elastic.co/t/getting-empty-value-in-script-field-in-kibana-5-2-1/104306/2 "2017-10-20T07:24:16Z")

</div>

A couple of things to check;

1. Are you sure you have those `msg_sent.keyword` and `user_msg_sent.keyword` fields

2. And that those fields are of type `string`

3. And that those fields are `Searchable` and `Aggregatable`  

4. Then also note that if you open Discover in one browser tab, and the scripted fields Management page in another tab, when you make a change to the scripted field, you have to `refresh` your Discover browser tab to get any changes you make to the scripted field to take affect.

5. Make sure you set the `Type` of the scripted field to `String`. This needs to match the return type and not the type of the values you are checking (which should both be strings in your case).

I assume you're not getting any error messages in Discover when you refresh the tab?

Please let us know if any of this helped.

Regards,  
Lee

---

<div class="post-metadata">

**Author:** ![rajkamalkool6](https://avatars.discourse-cdn.com/v4/letter/r/e9c0ed/32.png) [@rajkamalkool6](https://discuss.elastic.co/u/rajkamalkool6)\
**Post date:** [October 20, 2017, 8:30pm UTC](https://discuss.elastic.co/t/getting-empty-value-in-script-field-in-kibana-5-2-1/104306/3 "2017-10-20T20:30:16Z")

</div>

Those fileds are not aggregatable ? Do we need to make this field aggregable?

---

<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:** [November 17, 2017, 8:30pm UTC](https://discuss.elastic.co/t/getting-empty-value-in-script-field-in-kibana-5-2-1/104306/4 "2017-11-17T20:30:40Z")

</div>

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