# Scripted Fields not showing up in visualizations

**URL:** <https://discuss.elastic.co/t/scripted-fields-not-showing-up-in-visualizations/340417>\
**Category:** Kibana\
**Tags:** painless, visualisation\
**Created:** [August 9, 2023, 3:38am UTC](https://discuss.elastic.co/t/scripted-fields-not-showing-up-in-visualizations/340417 "2023-08-09T03:38:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas.kelly](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@thomas.kelly](https://discuss.elastic.co/u/thomas.kelly)\
**Post date:** [August 9, 2023, 3:38am UTC](https://discuss.elastic.co/t/scripted-fields-not-showing-up-in-visualizations/340417/1 "2023-08-09T03:38:14Z")

</div>

Hi, I am attempting to create a dashboard based off a scripted field. The scripted field is a pretty simple boolean evaluation, and I tested the expression using the preview results feature. The visualization I am attempting to make is a line graph and I am trying to split the series by this field that I created. However, the scripted field does not show up in the Terms or Significant Terms sub aggregations. I double checked and the visualization and scripted field are both created on the same index pattern. Does anyone know what might be going wrong?

---

<div class="post-metadata">

**Author:** ![Stratoula\_Kalafateli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stratoula_kalafateli/32/70923_2.png) [@Stratoula\_Kalafateli](https://discuss.elastic.co/u/Stratoula_Kalafateli)\
**Post date:** [August 9, 2023, 1:17pm UTC](https://discuss.elastic.co/t/scripted-fields-not-showing-up-in-visualizations/340417/2 "2023-08-09T13:17:36Z")

</div>

Which kibana version are you using? Are you using Lens or aggregation based visualizations? Also can you send the painless code that you generated your script?

---

<div class="post-metadata">

**Author:** ![thomas.kelly](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@thomas.kelly](https://discuss.elastic.co/u/thomas.kelly)\
**Post date:** [August 9, 2023, 1:40pm UTC](https://discuss.elastic.co/t/scripted-fields-not-showing-up-in-visualizations/340417/3 "2023-08-09T13:40:29Z")

</div>

I am not sure what kibana version Im using, I went to the management app but I cant find an "About" tab or a version listed anywhere. I am using aggregation based visualizations. Here is the painless script:

```auto
if (doc.containsKey('headers.user-agent')){
    return doc['headers.user-agent'].equals('CompanyAPI/1.0')
}else{
    return false
}

```

---

<div class="post-metadata">

**Author:** ![Stratoula\_Kalafateli](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stratoula_kalafateli/32/70923_2.png) [@Stratoula\_Kalafateli](https://discuss.elastic.co/u/Stratoula_Kalafateli)\
**Post date:** [August 10, 2023, 6:16am UTC](https://discuss.elastic.co/t/scripted-fields-not-showing-up-in-visualizations/340417/4 "2023-08-10T06:16:57Z")

</div>

The version appears in the top right corner

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/4/b4c94d125f10ad2f45f382fbc1f083b609938ac7.png)

To preview that the script has created successfully you can go to the "Get help with the syntax..." and check the preview results

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/e/8ec117765a6542ee632ee3941cb0645e6a913217.jpeg)

---

<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 7, 2023, 6:17am UTC](https://discuss.elastic.co/t/scripted-fields-not-showing-up-in-visualizations/340417/5 "2023-09-07T06:17:54Z")

</div>

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