Painless script condition in watcher

Hi I'm trying to make an alert system that matches following condition.

Each document has following fields.

  • status # either 'incomplete' or 'complete'
  • insert_time # timestamp when the document has been inserted

And the condition when I want alert to be sent is as follows.
select documents

  1. whose time difference between 'insert_time' and current_time stamp is greater than 20minutes
  2. whose status is incomplete.

My condition code is as follows.
( I haven't included 2) part here yet)

"condition": {
"compare": {
"((new Date().getTime()/1000)-doc['this_day'].value)/60" :
{ "gt" : 20
}
}
}

Alarm itself is working properly every one minute but not getting email. (not 'firing')
So I'm wondering what I've done wrong.

Thx in advance.

Best

Gee

Hey,

two things:

  • You are using a compare condition, which does not use scripting
  • You dont need a now date, you can use the scheduled time of the watch and use this for the comparison

You should also use the execute watch API and see if/how your watch gets executed.

--Alex

1 Like

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