Workato Tip: Avoiding infinite loops

Table of Contents

It can be easy to create an infinite loop by accident when you are creating integrations between systems. It’s important for you to know what causes this issue and how to fix it so you don’t wake up to runaway automation!

Prefer video? Check out this segment of our recent Product Hour:

Circular references lead to infinite loops

When we are creating automations, it’s not uncommon to take actions in the same system you are triggering your automation from. For example, you may have an automation that automatically creates a Jira issue whenever a Salesforce case is created. As a part of that automation, you might want to save the Jira issue key back to the Salesforce case for future reference. 

This creates a circular reference where the automation can continuously trigger itself! But don’t think you’re safe just because your recipe doesn’t follow this pattern. It’s still possible that your recipe can trigger another recipe in a different project, which in turn triggers your recipe, creating another circular reference!

These circular references can create infinite loops causing some major problems:

  1. Poor efficiency and resource usage: Infinite loops consume system resources unnecessarily, reducing the efficiency of your automation processes.
  2. Exponential task consumption: Each trigger can cause the next, leading to a rapid increase in the number of tasks being processed. This is especially problematic with real-time triggers as there is no delay between jobs!

Solution: Filter automated updates with trigger conditions

To prevent infinite loops, it’s crucial to filter automated updates by setting appropriate trigger conditions. This ensures that your automations are only activated by genuine business events and not by other automations.

Step-by-step implementation

Here’s a quick guide to adding trigger conditions to prevent infinite loops:

  1. Identify service account: Determine the ID of your service account. You can do this by checking job history records for previous automated updates, or by consulting with your system administrator. Bonus points: Save this service account ID as a project or environment property for easy reference in future recipes!
  2. Add trigger condition: Go to your recipe trigger and add a condition to check the Last Modified by ID or similar field. Set this condition to ignore changes made by the service account ID. Save your recipe with the new trigger condition and start your recipe.

And voila, just like that, you can stop worrying about infinite loops! You now have a robust automation that will ignore automated events from service accounts and only process real business events. This approach not only prevents infinite loops, but also increases the performance and reliability of your automated processes.

 

Was this post useful?

Get the best of Workato straight to your inbox.

Table of Contents