Preventing infinite loops in triggers

Plan requirement

Subscription Any plan
Access Admin

A trigger whose action satisfies its own conditions runs again. Zendesk stops it eventually, after the damage.

How a loop happens

A trigger's action counts as an update, and an update runs the triggers. So a rule that fires when priority is high and sets priority to high fires again on the update it just caused.

Two rules can do it between them, which is harder to spot: one sets a tag, the other reacts to the tag and changes a field the first watches.

What it looks like

  • A ticket with dozens of identical events seconds apart.
  • A customer receiving the same email repeatedly.
  • Your API usage rising sharply for no obvious reason.

Zendesk detects and stops runaway loops, but not before a customer has had ten copies of the same message.

The three defences

Use changed to, not is

A rule firing on a transition cannot fire again on the update it caused, because the transition already happened. This alone prevents most loops.

Exclude your own change

Add a condition on current user, or a tag the rule sets and then requires the absence of. Either makes the rule unable to react to itself.

Do not set what you test

The simplest discipline. If a trigger's condition and action touch the same field, look at it twice.

Mail loops are the version customers see. Two systems auto-replying to each other, or a rule emailing an address that forwards back in. Zendesk suspends most automated mail for exactly this reason, which is why an out-of-office reply does not create a ticket.

See also

Was this article helpful?

0

Still stuck?

Our support team will take a look with you.

Comments

0 comments

Article is closed for comments.