Accessing data of the watch itself

Hello,

We are working on some watches and wanted to add the condition threshold in hte output of the html email. Is there a way to access data of the watch itself somehow?

For example if this is the condition:

  "condition": {
    "compare": {
      "ctx.payload.hits.total": {
        "gte": 2
      }
    }
  }

How could we access the threshold key 'ctx.payload.hits.total' and value '2' so we can use this in for example an email action?

Grtz

Willem

you can use mustache to access parts of the payload like {{ctx.payload.hits.total}}

--Alex

Alex,

Yes, I know that, but data from the watch itself, such as the threshold in the condition is not in the payload...

Grtz

Willem

this is true. The payload represents only the input itself. If you want to do that, you could store the threshold in the metadata and use a script condition and do sth like return ctx.payload.hits.total > ctx.metadata.threshold

--Alex

Alex,

Ok, I see. And can I use the values in the metadata in the condition? Then I could add

"metadata" : { "threshold" : "5" }

And refer to it in the condition?

"condition" : { "compare" : { "ctx.payload.hits.total" : { "gt" : {{ctx.metadata.threshold}} }}

Willem

just use a script condition like I did above instead of a compare and everything will work.

Alex, We were able to use the Metadata in the condition. Thanks!

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