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

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?

Hey,

as mustache is a template only language with no logic, you need to do this before hand. You can use a script transform to do this.

--Alex

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.