# Kibana Groovy Scripted Field for Aggregation: Visualize: Unsupported script value

**URL:** https://discuss.elastic.co/t/kibana-groovy-scripted-field-for-aggregation-visualize-unsupported-script-value/54126
**Category:** Kibana
**Created:** [June 28, 2016, 8:11am UTC](https://discuss.elastic.co/t/kibana-groovy-scripted-field-for-aggregation-visualize-unsupported-script-value/54126 "2016-06-28T08:11:43Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)
#### Post date: [June 28, 2016, 4:29pm UTC](https://discuss.elastic.co/t/kibana-groovy-scripted-field-for-aggregation-visualize-unsupported-script-value/54126/2 "2016-06-28T16:29:02Z")

</div>

Hi Benjamin,

Try changing this:

```
{
"script": "doc['@timestamp'].date.dayOfWeek().getAsText()",
"lang" : "groovy"
}

```

To this:

```
{
"script": "doc['@timestamp'].date.dayOfWeek().getAsText()",
"lang" : "groovy",
"valueType": "string"
}

```

By the way, I was able to get this working a slightly different way (but I don't think it is better or worse than yours):

When you create the scripted field, you can enter the script, `doc['@timestamp'].date.dayOfWeek().getAsText()` in the scripted field definition itself:

 ![](https://us1.discourse-cdn.com/elastic/original/2X/d/dbfcb1f172ca40a02ab7021abe3dc3032aea51df.png)

Then, in the visualization editor, in the advanced section for the terms aggregation on the scripted field, you only need to specify `{ "lang": "groovy", "valueType": "string" }`:

 ![](https://us1.discourse-cdn.com/elastic/original/2X/d/d8fcf144e6b56f335d880a3cdfb4c7dd2a9b58e4.png)

---

_[View the full topic](https://discuss.elastic.co/t/kibana-groovy-scripted-field-for-aggregation-visualize-unsupported-script-value/54126)._
