[SOLVED] The rule triggering cause

Hi,

I have a rule which is triggered by cron job (time) and by item event. When rule is fired, I want to know what is the triggering cause (time / item event).

Is there a way to know it?

Thx

I think I found an answer here

I think:

rule "Test"
when
    Time cron "1 0 0 ? * * *" or
    Item myItem changed
then
    if (triggeringItem !== null) {
        // Rule triggered by Item
    } else {
        // Rule triggered by cron
    }
end
1 Like

Get rid of the . name on the first if statement or the rule will throw an exception saying that null doesn’t have a .name method when the rule is triggered by the time trigger.

1 Like