Expand my Community achievements bar.

Is there an official way to identify what triggered a rule in the condition code?

Avatar

Level 1

We're running into a situation where we basically want a rule to hit two triggers before processing. I noticed if you look at the arguments variable in a Custom Code function in the Conditions, you can get this object from the first item in the array:

  1. {
    1. $rule: {id: "RULE_ID", name: "RULE_NAME"}
    2. $type: "core.dom-ready"
    3. element: document
    4. nativeEvent: Event {isTrusted: true, type: "DOMContentLoaded", target: document, currentTarget: document, eventPhase: 2, …}
    5. target: document
    6. }

Which is awesome - that's basically what I wanted to grab so I could keep track of what had already been called. However, I don't know if this is documented, and I want to make sure that I'm not going to use something that could be removed without warning. I know the nativeEvent is provided on the page (if present) as the variable event. This wasn't available for the other condition though, which was a direct call. I know I could get around it in a handwave-y way right now (event being present == dom ready call, event not being present == direct call) but if I really want to get messed up and add a third condition in the future, that won't work anymore.

Any recommended approaches for something like this?

0 Replies