# Multiple script/condition for a watcher

**URL:** <https://discuss.elastic.co/t/multiple-script-condition-for-a-watcher/100051>\
**Category:** Elasticsearch\
**Created:** [September 11, 2017, 12:43pm UTC](https://discuss.elastic.co/t/multiple-script-condition-for-a-watcher/100051 "2017-09-11T12:43:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Benjamin\_Peere](https://avatars.discourse-cdn.com/v4/letter/b/f04885/32.png) [@Benjamin\_Peere](https://discuss.elastic.co/u/Benjamin_Peere)\
**Post date:** [September 11, 2017, 12:43pm UTC](https://discuss.elastic.co/t/multiple-script-condition-for-a-watcher/100051/1 "2017-09-11T12:43:40Z")

</div>

hello everyone,  
i am wondering if it is possible to have multiple conditions or script for a watcher, to do Something like this :

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/a/8a38c15647624deca43207d8f65a3e757c3ff3f2.png)  
or like this :  
 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/3/43e496f9a287c4df11df72be2b5df72361ced45a.png)  
obviously this doesn't work, but i would like to know how to make it work so i can create only 1 watcher for all my conditions instead of 6.

thanks for your help and your reply!

---

<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:** [September 11, 2017, 12:59pm UTC](https://discuss.elastic.co/t/multiple-script-condition-for-a-watcher/100051/2 "2017-09-11T12:59:07Z")

</div>

hey,

you can just do `return ctx.payload.foo > 12 && ctx.payload.bar != 'baz'` and that will work.

--Alex

---

<div class="post-metadata">

**Author:** ![Benjamin\_Peere](https://avatars.discourse-cdn.com/v4/letter/b/f04885/32.png) [@Benjamin\_Peere](https://discuss.elastic.co/u/Benjamin_Peere)\
**Post date:** [September 11, 2017, 1:08pm UTC](https://discuss.elastic.co/t/multiple-script-condition-for-a-watcher/100051/3 "2017-09-11T13:08:02Z")

</div>

thanks for your reply!  
i tried this :

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/1/b16d44ed5846638188e8603bdb4ac9a8906345af.png)  
but it still doesn't work

---

<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:** [September 11, 2017, 1:27pm UTC](https://discuss.elastic.co/t/multiple-script-condition-for-a-watcher/100051/4 "2017-09-11T13:27:02Z")

</div>

Please stop using screenshots and use snippets.

Also, please stop telling that it doesnt work, but try to provide context. What exactly does not work, is there an error message, is there an exception, have you tried to run the execute watch API and can you paste the output.

I suppose that you cannot access `payload` because it must be `ctx.payload`, please check the existing examples, we have a fair share of them in our [examples repo](https://github.com/elastic/examples/tree/master/Alerting)

---

<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:** [October 9, 2017, 1:27pm UTC](https://discuss.elastic.co/t/multiple-script-condition-for-a-watcher/100051/5 "2017-10-09T13:27:17Z")

</div>

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