# Rules Jobs

Rules are profoundly powerful in Orderwave, allowing you to apply your custom business rules to affect orders, shipments, payments, batching, returns, and so much more. However, rules are event-based, since they rely on triggers to run on individual items in their bucket.

Rules jobs are automated tasks that let you specify that rules should be run on data in a bucket, without being triggered by a specific trigger. For example, you find that you would like to bulk-change a value on a group of orders, using a rules job, you can create an automated task that will use a search-filter to locate the order, and run the rule on those orders.

WARNING

Like rules on their own, rules jobs are powerful. But unlike rules, which run on one item at time with triggers, rules jobs allow you to batch-run rules on large amounts of items. A poorly tested or poorly configured rule can cause a large amount of actions (changes, deletions, emails, etc). Proceed with caution.

To get started, you will need the following:

# Create a search-filter for a rules job

When creating a search-filter that you intend to use on a rules job, there are some things to consider. For example:

  • If your rule changes a value, it is a good idea to create a search-filter that specifies that the value is not already what you want it to be.
  • If your rule adds the item to a queue, it is a good idea that your search-filter specifies that it is not already in that queue.
  • If your rule tags the item, it is a good idea that your search-filter specifies that it is not already tagged with that tag.

Ideally, your search-filter will find the least amount of items that need to be processed by the rule. In this way, you will avoid creating a needlessly long-running task that could delay other scheduled automated tasks.

# Create the rule for a rules job

A rules job requires a rule. Create a new rule that performs the action that you require. When choosing the trigger, make sure that you choose on demand as the trigger, as only on demand rules are available to rules jobs.

TIP

You can re-use an existing rule to keep things simple. Just enable the on demand trigger on that rule.

# Create a rules job

Create an automated task with whatever recurrence options you require. For the properties of the automated task, choose the following:

Section Description
Task type Rules job
Bucket The bucket that you want to search and perform the rule on.
Search filter The saved-search filter on the bucket that will be used to perform the search on that bucket. Only search-filters that are "shared" are available in rules jobs, so that any administrator can see them and use them.
Rule The rule to run on each item in the bucket.

That is all that is required to set loose this powerful functionality. Activate your automated task, and let it perform the actions you need.