# Kibana painless scripted fields. Loop on array of objects

**URL:** <https://discuss.elastic.co/t/kibana-painless-scripted-fields-loop-on-array-of-objects/132847>\
**Category:** Kibana\
**Created:** [May 22, 2018, 3:20pm UTC](https://discuss.elastic.co/t/kibana-painless-scripted-fields-loop-on-array-of-objects/132847 "2018-05-22T15:20:06Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![ramchjob](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ramchjob/32/31480_2.png) [@ramchjob](https://discuss.elastic.co/u/ramchjob)\
**Post date:** [May 22, 2018, 4:27pm UTC](https://discuss.elastic.co/t/kibana-painless-scripted-fields-loop-on-array-of-objects/132847/5 "2018-05-22T16:27:44Z")

</div>

The error still the same after l.toArray();

Below is the screenshot of the same. I see only few datatypes

string, number, boolean , date in type dropdown. After checking elastic search logs, ES itself not liking the script and throwing the exception

`Caused by: java.lang.invoke.WrongMethodTypeException: cannot convert MethodHandle(List)int to (Object)boolean`

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/6/36ccdac396fa4f2e96554f934214585bf58e08cf.png)

---

_[View the full topic](https://discuss.elastic.co/t/kibana-painless-scripted-fields-loop-on-array-of-objects/132847)._
