# Adding a field, view painless script error

**URL:** <https://discuss.elastic.co/t/adding-a-field-view-painless-script-error/333505>\
**Category:** Elasticsearch\
**Tags:** painless\
**Created:** [May 15, 2023, 8:32pm UTC](https://discuss.elastic.co/t/adding-a-field-view-painless-script-error/333505 "2023-05-15T20:32:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marscar](https://avatars.discourse-cdn.com/v4/letter/m/bbce88/32.png) [@marscar](https://discuss.elastic.co/u/marscar)\
**Post date:** [May 15, 2023, 8:32pm UTC](https://discuss.elastic.co/t/adding-a-field-view-painless-script-error/333505/1 "2023-05-15T20:32:06Z")

</div>

Hello and thanks for advance for the help.

I am trying to create a new variable in elastic, but no matter what I put in the painless script editor, I get painless script invalid. I would try to debug, but I can't seem to open any error descriptor, meaning I can't see any specific error message beyond the "Painless script invalid". Does anyone know how to see the full error message, or can provide any guidance on how to write a valid painless script? Thank you so much.

 ![d268e290677b069ff3331d3480d59cd642d007b4](https://us1.discourse-cdn.com/elastic/original/3X/b/1/b10a93b8dd8440adb833ea3494cdda30c0357843.png)

---

<div class="post-metadata">

**Author:** ![Priscilla\_Parodi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/priscilla_parodi/32/43047_2.png) [@Priscilla\_Parodi](https://discuss.elastic.co/u/Priscilla_Parodi)\
**Post date:** [June 7, 2023, 7:45pm UTC](https://discuss.elastic.co/t/adding-a-field-view-painless-script-error/333505/2 "2023-06-07T19:45:47Z")

</div>

Hello @marscar, welcome to the community!

[This guide](https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-guide.html) can be helpful for learning about the language.

To debug, painless has a utility method called [Debug.explain](https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-debugging.html) which throws the exception for you.

Hope it helps!

---

<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:** [July 5, 2023, 7:45pm UTC](https://discuss.elastic.co/t/adding-a-field-view-painless-script-error/333505/3 "2023-07-05T19:45:53Z")

</div>

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