# Watcher : Email Action : How to use attributes with special characters in the name

**URL:** <https://discuss.elastic.co/t/watcher-email-action-how-to-use-attributes-with-special-characters-in-the-name/239532>\
**Category:** Elasticsearch\
**Created:** [July 1, 2020, 7:02pm UTC](https://discuss.elastic.co/t/watcher-email-action-how-to-use-attributes-with-special-characters-in-the-name/239532 "2020-07-01T19:02:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lalit\_Negi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lalit_negi/32/71492_2.png) [@Lalit\_Negi](https://discuss.elastic.co/u/Lalit_Negi)\
**Post date:** [July 1, 2020, 7:02pm UTC](https://discuss.elastic.co/t/watcher-email-action-how-to-use-attributes-with-special-characters-in-the-name/239532/1 "2020-07-01T19:02:03Z")

</div>

I have a query result where the source has some attributes with speical chars in name

`ctx.payload.hits.hits[0]._source['@msg']`

and I want to send these attributes in a watcher email action.

however these kind of attributes never work under the transform =\> script =\> source section  
I tried many things like replacing the attribute with \_ etc , using a varible like  
`def attr = '@msg'`  
but nothing works

below is a sample example (formatted the source string for easy understanding

```auto
    "transform": {
        "script": {
          "source": "ctx.payload.transform = [];
                    def document = [];     
                    for (int j = 0; j < ctx.payload.hits.hits.length; j++) {
                      def src = ctx.payload.hits.hits[j]._source;    
                      document = ['details': src['@mt'] ];  
                      ctx.payload.transform.add(document); 
                    }     
                    return ctx.payload.transform;",
          "lang": "painless"
        }
      }

```

Kindly suggest any way to access these attribute in the watchers email painless script please.

Thanks in advance

---

<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 29, 2020, 7:02pm UTC](https://discuss.elastic.co/t/watcher-email-action-how-to-use-attributes-with-special-characters-in-the-name/239532/2 "2020-07-29T19:02:04Z")

</div>

Closed on July 29, 2020, 7:02pm UTC

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