# Script throwing error on visualisations: Caused by: java.lang.IllegalArgumentException: invalid sequence of tokens near \['}'\]

**URL:** https://discuss.elastic.co/t/script-throwing-error-on-visualisations-caused-by-java-lang-illegalargumentexception-invalid-sequence-of-tokens-near/246150
**Category:** Kibana
**Tags:** painless
**Created:** [August 24, 2020, 3:25pm UTC](https://discuss.elastic.co/t/script-throwing-error-on-visualisations-caused-by-java-lang-illegalargumentexception-invalid-sequence-of-tokens-near/246150 "2020-08-24T15:25:23Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![twright8](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/twright8/32/58294_2.png) [@twright8](https://discuss.elastic.co/u/twright8)
#### Post date: [August 24, 2020, 3:25pm UTC](https://discuss.elastic.co/t/script-throwing-error-on-visualisations-caused-by-java-lang-illegalargumentexception-invalid-sequence-of-tokens-near/246150/1 "2020-08-24T15:25:23Z")

</div>

My script:  
`if (doc['companiesHouse.date_of_creation'].size()>0 && doc['awards.date'].size() > 0) { return ((doc['awards.date'].value.getMillis() - doc['companiesHouse.date_of_creation'].value.getMillis()) / 86400000); } return "";`

both existing fields are mapped as dates.

Any advice would be appreciated!

Thanks,

Tom

---

<div class="post-metadata">

### Author: ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)
#### Post date: [August 25, 2020, 6:39pm UTC](https://discuss.elastic.co/t/script-throwing-error-on-visualisations-caused-by-java-lang-illegalargumentexception-invalid-sequence-of-tokens-near/246150/2 "2020-08-25T18:39:31Z")

</div>

Hello @twright8

Which version of the elastic stack are you using? Have you tried using the painless lab? [https://www.elastic.co/guide/en/kibana/current/painlesslab.html](https://www.elastic.co/guide/en/kibana/current/painlesslab.html)

---

<div class="post-metadata">

### Author: ![twright8](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/twright8/32/58294_2.png) [@twright8](https://discuss.elastic.co/u/twright8)
#### Post date: [August 26, 2020, 2:04pm UTC](https://discuss.elastic.co/t/script-throwing-error-on-visualisations-caused-by-java-lang-illegalargumentexception-invalid-sequence-of-tokens-near/246150/3 "2020-08-26T14:04:10Z")

</div>

7.9! I dont really know how to use painless lab. is it worth learning then?

---

<div class="post-metadata">

### Author: ![mattkime](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mattkime/32/43522_2.png) [@mattkime](https://discuss.elastic.co/u/mattkime)
#### Post date: [August 26, 2020, 2:43pm UTC](https://discuss.elastic.co/t/script-throwing-error-on-visualisations-caused-by-java-lang-illegalargumentexception-invalid-sequence-of-tokens-near/246150/4 "2020-08-26T14:43:49Z")

</div>

painless lab provides some IDE and debugging functionality which can be very useful when troubleshooting painless scripts.

---

<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: [September 23, 2020, 2:43pm UTC](https://discuss.elastic.co/t/script-throwing-error-on-visualisations-caused-by-java-lang-illegalargumentexception-invalid-sequence-of-tokens-near/246150/5 "2020-09-23T14:43:50Z")

</div>

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