# Script condition and ctx.vars

**URL:** <https://discuss.elastic.co/t/script-condition-and-ctx-vars/37701>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [December 21, 2015, 2:53pm UTC](https://discuss.elastic.co/t/script-condition-and-ctx-vars/37701 "2015-12-21T14:53:08Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![mcku](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mcku/32/33775_2.png) [@mcku](https://discuss.elastic.co/u/mcku)\
**Post date:** [December 24, 2015, 10:44am UTC](https://discuss.elastic.co/t/script-condition-and-ctx-vars/37701/3 "2015-12-24T10:44:08Z")

</div>

Actually, I was inspired by this post:

> [@Adding data in the ctx](https://discuss.elastic.co/t/adding-data-in-the-ctx/24680/2):
>
> Any script in a watch can add variables to the context. For example something like this can be added to a script condition: ctx.vars.my\_var=5; return ctx.vars.my\_var \<= 5; Once a context variable has been defined it is accessible in all places of a Watch that supports scripting. So in the above example the ctx.vars.my\_var can also be checked in a script transform elsewhere in the Watch. Context variables are scoped to the watch execution to are defined in. Context variables aren't stored in th…

As a `transform` and `condition`supports scripting, they should have access to `ctx.vars`. Is this falsified already or still valid, wondering, especially the vendor perspective would be important here as this is a commercial component.

The use case is very significant I think, such as increasing dimensionality of watch evaluations by causal relationships. In that sense, chain inputs and chain transforms together would provide with huge flexibility and would expand the usability of watcher, which is a huge step. Kudos for that.  
(But at my small step here now, I am still kinda stuck!)

Thanks anyway...

---

_[View the full topic](https://discuss.elastic.co/t/script-condition-and-ctx-vars/37701)._
