Skip to content
  • There are no suggestions because the search field is empty.

How to fire a trigger only for certain products using a conditional expression

Set a condition on a trigger so it only fires when the job, shift or product matches a rule you define, using match regex to check text like an order description.

What you'll build

  • A trigger that fires on every job start, but only when the product meets a condition you set.
  • A condition that checks the text in a field, so one trigger covers a whole product group instead of a list of individual SKUs.

Step 1 — Work out which products need the check

Start with the outcome, not the rule. Take a plastic bottle check that only applies to PET products:

Order description Bottle type Check needed?
CHERRY-GLSBTL300 Glass No
CHERRY-PETBTL300 PET Yes
LIME-GLSBTL300 Glass No
LIME-PETBTL300 PET Yes

The products that need the check all have PET somewhere in the order description. That shared piece of text is what the condition will look for.

Step 2 — Open the trigger and turn on the conditional expression

Any Job, Shift, State or Relay trigger can have a condition added. Open the trigger, go to the Conditional Expression tab, and switch Enable Conditional Expression to on.

The condition looks at the metadata for the job, shift or product. When the condition is true the trigger fires. When it is false, nothing happens.

Screenshot 2026-09-10 at 7.12.43 pm

Step 3 — Build the condition

The expression is built from three parts, left to right:

  • The field you want to check, chosen from Product Data or Special Fields. In this example, orderDescription.
  • The operator. In this example, match regex.
  • The value to look for, entered under Value. In this example, PET.

Read the finished rule as a sentence: when the order description contains PET, the expression is true and the trigger fires.

image2-1

Step 4 — Save and check the trigger summary

Save the trigger. The summary line at the top of the trigger window shows the trigger type, the timing and that a condition is applied, for example a job start trigger set to run after 1000 In, then every 1000 In, marked as conditional.


What match regex is doing

match regex works like the Find tool in a word processor: it searches the field for the text you give it. It is far more capable than a plain Find, because it matches a pattern rather than fixed text.

That matters when you do not know the exact value in advance. Compare these:

Input Expression Match?
CHERRY-GLSBTL300 PET No
CHERRY-PETBTL300 PET Yes
CHERRY-1GLSBTL330 \d{3} Yes
CHERRY-2GLSBTL650 \d{3} Yes

In the last two rows, \d stands for any digit and {3} means three of them in a row. The pattern matches both codes even though the numbers differ.

A few patterns that cover most factory cases:

  • \d any digit, [A-Z] any uppercase letter, [A-Z0-9] any uppercase letter or digit.
  • {3} exactly three of the preceding item.
  • ^ start of the text, $ end of the text.

Regex Cheat Sheet

ofs-regex-cheatsheet (1)


Adapting it to your own products

  • Swap orderDescription for whichever field carries the text you need to test. The fields available depend on the product data your site sends to OFS.
  • Choose a piece of text that is present in every product that needs the check, and absent from every product that does not. If your product codes do not share a clean marker, add one to the product data rather than building a long expression.
  • A condition can be added to Shift and State triggers the same way, so the same approach works for checks tied to a shift or a downtime state.