# Unsupported script value error in visual

**URL:** https://discuss.elastic.co/t/unsupported-script-value-error-in-visual/259800
**Category:** Kibana
**Created:** [December 29, 2020, 1:37pm UTC](https://discuss.elastic.co/t/unsupported-script-value-error-in-visual/259800 "2020-12-29T13:37:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Rajesh\_M](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajesh_m/32/60701_2.png) [@Rajesh\_M](https://discuss.elastic.co/u/Rajesh_M)
#### Post date: [December 29, 2020, 1:37pm UTC](https://discuss.elastic.co/t/unsupported-script-value-error-in-visual/259800/1 "2020-12-29T13:37:27Z")

</div>

Hi,

I am using ELK 7.6.2.  
In my index, there are two fields, timestamp and duration (duration is in ms). I have created a new field using painless script to find the start time (`timestamp` - `duration`). Below is my scripted field,

```auto
    if (doc['duration_ms'].size() != 0) { 
          return new Date(doc['@timestamp'].value.getMillis()-doc['duration_ms'].value)
    }

```

The preview works as expected and able to see the correct data in "Discover" too. But when i create a visual, i get "unsupported script value error".

```auto
    {
      "took": 152,
      "timed_out": false,
      "_shards": {
        "total": 180,
        "successful": 179,
        "skipped": 178,
        "failed": 1,
        "failures": [
          {
            "shard": 0,
            "index": "logstash_access_sshd-2020.12.29",
            "node": "3Lg1Rhn9RqWYnSXA68z17A",
            "reason": {
              "type": "aggregation_execution_exception",
              "reason": "Unsupported script value [Tue Dec 29 11:08:30 EET 2020], expected a number, date, or boolean"
            }
          }
        ]
      },
      "hits": {
        "total": 0,
        "max_score": null,
        "hits": []
      },
      "aggregations": {
        "2": {
          "doc_count_error_upper_bound": 0,
          "sum_other_doc_count": 0,
          "buckets": []
        }
      }
    }

```

is still the custom scripted fields not supported on visuals(mainly i need in data table)?

-Thanks

---

<div class="post-metadata">

### Author: ![jbudz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jbudz/32/45922_2.png) [@jbudz](https://discuss.elastic.co/u/jbudz)
#### Post date: [December 29, 2020, 7:36pm UTC](https://discuss.elastic.co/t/unsupported-script-value-error-in-visual/259800/2 "2020-12-29T19:36:52Z")

</div>

Unfortunately it's not supported currently. There's an open issue for it at [https://github.com/elastic/kibana/issues/69121](https://github.com/elastic/kibana/issues/69121) which has more details. Probably the closest workaround is to create a secondary field at index time.

---

<div class="post-metadata">

### Author: ![Rajesh\_M](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajesh_m/32/60701_2.png) [@Rajesh\_M](https://discuss.elastic.co/u/Rajesh_M)
#### Post date: [December 29, 2020, 7:51pm UTC](https://discuss.elastic.co/t/unsupported-script-value-error-in-visual/259800/3 "2020-12-29T19:51:52Z")

</div>

Thanks @jbudz. I'll follow the issue on GitHub and try the workaround. 🙂

---

<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: [January 26, 2021, 7:51pm UTC](https://discuss.elastic.co/t/unsupported-script-value-error-in-visual/259800/4 "2021-01-26T19:51:54Z")

</div>

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