# Is there a way to configure email title as "error occurs at {{ctx.trigger.scheduled\_time}}||-1m"?

**URL:** <https://discuss.elastic.co/t/is-there-a-way-to-configure-email-title-as-error-occurs-at-ctx-trigger-scheduled-time-1m/32381>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-alerting\
**Created:** [October 16, 2015, 11:16am UTC](https://discuss.elastic.co/t/is-there-a-way-to-configure-email-title-as-error-occurs-at-ctx-trigger-scheduled-time-1m/32381 "2015-10-16T11:16:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enniu\_51](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enniu_51/32/5310_2.png) [@Enniu\_51](https://discuss.elastic.co/u/Enniu_51)\
**Post date:** [October 16, 2015, 11:16am UTC](https://discuss.elastic.co/t/is-there-a-way-to-configure-email-title-as-error-occurs-at-ctx-trigger-scheduled-time-1m/32381/1 "2015-10-16T11:16:18Z")

</div>

I set the email title to `error occurs at {{ctx.trigger.scheduled_time}}||-1m`.

But I receive emails whose title is something like:

```
error occurs at 2015-10-16T11:06:00.000Z||-1m

```

I know this worked `{{ctx.trigger.scheduled_time}}||-1m` in range configuration, but how to do the similar things with email title?

---

<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:** [October 19, 2015, 8:05am UTC](https://discuss.elastic.co/t/is-there-a-way-to-configure-email-title-as-error-occurs-at-ctx-trigger-scheduled-time-1m/32381/2 "2015-10-19T08:05:45Z")

</div>

Hey,

as mustache is a template only language with no logic, you need to do this before hand. You can use a [script transform](https://www.elastic.co/guide/en/watcher/current/transform.html#transform-script) to do this.

--Alex

---

<div class="post-metadata">

**Author:** ![Enniu\_51](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/enniu_51/32/5310_2.png) [@Enniu\_51](https://discuss.elastic.co/u/Enniu_51)\
**Post date:** [October 20, 2015, 4:08am UTC](https://discuss.elastic.co/t/is-there-a-way-to-configure-email-title-as-error-occurs-at-ctx-trigger-scheduled-time-1m/32381/3 "2015-10-20T04:08:32Z")

</div>

```
DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
DateTime scheduleTime = fmt.parseDateTime(ctx.trigger.triggered_time.toString());
Period period = ISOPeriodFormat.standard().parsePeriod("P" + range);
DateTime beginTime = scheduleTime.minus(period);
return beginTime;

```

I write such a groovy script, but as document stated, that will create a new payload with a single field `beginTime`. But I want to use `ctx.trigger.triggered_time` also(now my email title is `error occurs in [{{beginTime}}, {{ctx.trigger.scheduled_time}}]`). What is the prefer way to handle that? Return a class which contains both instead?

* * *

EDIT: Sorry for my carelessness, I saw this in the doc:

> The executed script may either return a valid model that is the equivalent of a Java™ Map or a JSON object (you will need to consult the documentation of the specific scripting language to find out what this construct is). Any other value that is returned will be assigned and accessible to/via the \_value variable.

---

<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 6, 2017, 1:48pm UTC](https://discuss.elastic.co/t/is-there-a-way-to-configure-email-title-as-error-occurs-at-ctx-trigger-scheduled-time-1m/32381/4 "2017-07-06T13:48:19Z")

</div>


