# How to get the value of an array using ctx.payload

**URL:** <https://discuss.elastic.co/t/how-to-get-the-value-of-an-array-using-ctx-payload/286864>\
**Category:** Elasticsearch\
**Created:** [October 15, 2021, 5:09pm UTC](https://discuss.elastic.co/t/how-to-get-the-value-of-an-array-using-ctx-payload/286864 "2021-10-15T17:09:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![StephaneRodier](https://avatars.discourse-cdn.com/v4/letter/s/ed8c4c/32.png) [@StephaneRodier](https://discuss.elastic.co/u/StephaneRodier)\
**Post date:** [October 15, 2021, 8:19pm UTC](https://discuss.elastic.co/t/how-to-get-the-value-of-an-array-using-ctx-payload/286864/2 "2021-10-15T20:19:27Z")

</div>

Hello, I just found in another topic that Mustache does not like "." in the variables and a transformation is required as described below

> [@Unable to access payload \_source fields using Watcher foreach with rollup data](https://discuss.elastic.co/t/unable-to-access-payload-source-fields-using-watcher-foreach-with-rollup-data/221049/2):
>
> I resolved the issue. Mustache is not able to access fields with a dot inside them. I added a transform action, where I changed the field name, and then logged it out. "transform": { "script": { "lang" : "painless", "inline": "ctx.payload.hits.hits.forEach(hit -\> hit.\_source.service\_name\_terms\_count = hit.\_source['service.name.terms.\_count']); return ctx.payload" } } "text": "Found ##{{ctx.payload.\_id}}## at ##{{ctx.payload.\_source.service\_name\_terms\_count}}##"

---

_[View the full topic](https://discuss.elastic.co/t/how-to-get-the-value-of-an-array-using-ctx-payload/286864)._
