# How get the Action ID in script

**URL:** <https://discuss.elastic.co/t/how-get-the-action-id-in-script/107206>\
**Category:** Elasticsearch\
**Created:** [November 10, 2017, 3:22pm UTC](https://discuss.elastic.co/t/how-get-the-action-id-in-script/107206 "2017-11-10T15:22:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RomainXie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/romainxie/32/22427_2.png) [@RomainXie](https://discuss.elastic.co/u/RomainXie)\
**Post date:** [November 10, 2017, 3:22pm UTC](https://discuss.elastic.co/t/how-get-the-action-id-in-script/107206/1 "2017-11-10T15:22:21Z")

</div>

Hi,

In the Watcher, I have two actions which output to Slack. In the payload send to Slack, I want to inside the current Action ID. But I don't find a var contain the action id in the ctx.  
I want get the ID of the action which is calling the transform.

Can get the Action ID from the context? Or, I have to write it in the script of the transform in each action?

Thanks.

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 13, 2017, 8:17am UTC](https://discuss.elastic.co/t/how-get-the-action-id-in-script/107206/2 "2017-11-13T08:17:58Z")

</div>

Hey,

the action id cannot be retrieved from the context currently, as the actions cannot enrich the context. A script transform would indeed solve this (or of course just hard coding in the action itself).

--Alex

---

<div class="post-metadata">

**Author:** ![RomainXie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/romainxie/32/22427_2.png) [@RomainXie](https://discuss.elastic.co/u/RomainXie)\
**Post date:** [November 13, 2017, 1:26pm UTC](https://discuss.elastic.co/t/how-get-the-action-id-in-script/107206/3 "2017-11-13T13:26:06Z")

</div>

Hi, @spinscale

Thank for your answer.  
Your means I can get the Action ID in the transform which include the action?  
How do it 😄  
May you post a sample?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [November 13, 2017, 2:10pm UTC](https://discuss.elastic.co/t/how-get-the-action-id-in-script/107206/4 "2017-11-13T14:10:35Z")

</div>

Hey,

sorry if I was not clear. There is no way to do this, you need to do it manually, like this

```auto
"transform" : {
  "script" : "def payload = ctx.payload ; payload.action = 'your_action_name' ; return payload"
}

```

--Alex

---

<div class="post-metadata">

**Author:** ![RomainXie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/romainxie/32/22427_2.png) [@RomainXie](https://discuss.elastic.co/u/RomainXie)\
**Post date:** [November 13, 2017, 5:30pm UTC](https://discuss.elastic.co/t/how-get-the-action-id-in-script/107206/5 "2017-11-13T17:30:52Z")

</div>

Thank you @spinscale

---

<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:** [December 11, 2017, 5:30pm UTC](https://discuss.elastic.co/t/how-get-the-action-id-in-script/107206/6 "2017-12-11T17:30:59Z")

</div>

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