# Scripted Field Problem in Kibana

**URL:** <https://discuss.elastic.co/t/scripted-field-problem-in-kibana/126549>\
**Category:** Kibana\
**Created:** [April 3, 2018, 10:47am UTC](https://discuss.elastic.co/t/scripted-field-problem-in-kibana/126549 "2018-04-03T10:47:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Debashis\_Adak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/debashis_adak/32/46087_2.png) [@Debashis\_Adak](https://discuss.elastic.co/u/Debashis_Adak)\
**Post date:** [April 3, 2018, 10:47am UTC](https://discuss.elastic.co/t/scripted-field-problem-in-kibana/126549/1 "2018-04-03T10:47:41Z")

</div>

Hi,

I am new to scripted field in Kibana. Kindly find my below mentioned code. This code is always returning "Message is Null" though I can find value for "message" field in Kibana. Can you please help me to resolve this issue?

* * *

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* CODE \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

* * *

if(doc.containsKey('message.keyword'))  
{  
def message = doc['message.keyword'].value;

if (message!=null)  
{  
return "Message is Not Null";  
}  
else  
{  
return "Message is Null";  
}  
}  
return "There is no field";

* * *

* * *

Thanks in Advanced...

Debashis Adak

---

<div class="post-metadata">

**Author:** ![Bargs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bargs/32/5429_2.png) [@Bargs](https://discuss.elastic.co/u/Bargs)\
**Post date:** [April 4, 2018, 8:57pm UTC](https://discuss.elastic.co/t/scripted-field-problem-in-kibana/126549/2 "2018-04-04T20:57:20Z")

</div>

@Debashis_Adak I just tested your script and it's working for me. Are you sure the name of your field is `message.keyword`? I would try simplifying the script to test each piece at a time. First try just returning the contents of `message.keyword` and see what you get.

---

<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:** [May 2, 2018, 8:57pm UTC](https://discuss.elastic.co/t/scripted-field-problem-in-kibana/126549/3 "2018-05-02T20:57:24Z")

</div>

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