Fluent Commerce Logo
Docs

Create Custom Sourcing Criterion

How-to Guide

Author:

Kirill Gaiduk

Changed on:

3 Mar 2026

Key Points

  • Outcome: You’ll extend the Responsive Sourcing Framework with a Custom Criterion and apply it in real Strategies
  • Minimal essentials: Implement the Criterion → register it → expose it in the Setting (auto-generate or manual) → verify behavior
  • Application: Influence Location ranking (exclusion) with domain-specific scoring that fits your business

Steps

Step arrow right iconPreliminary Setup

Custom Sourcing Criterion creation requires modifying the Sourcing Utilities bundle:1. Prepare your module that contains Order Reference Module assets.2. Download the Sourcing Utilities Package (Java source code).3. Add Sourcing Utilities as a dependency in your project's `pom.xml` file.

Step arrow right iconImplement a Custom Sourcing Criterion Function

Create a class that enforces your ranking (exclusion) logic:
  • Implement `SourcingCriterion` (or extend `BaseSourcingCriterion`)
  • Put computation in `execute(CriterionContext ctx)` (when extending `BaseSourcingCriterion`)
  • Parse configuration in `parseParams(JsonNode params)` if needed
  • (Optional) Override `normalize(min, max, rating)` when your metric is “lower is better” (e.g., distance)

Step arrow right iconIntroduce Custom Sourcing Rules

Introduce custom versions of the Sourcing Rules that will execute your sourcing logic inside your plugin.1. Copy the reference Sourcing Rule implementation:2. Rename the class3. Register your custom Sourcing Condition or Criterion inside the Rule class4. Replace the reference Rule in your Workflow configuration with your custom Rule

Step arrow right iconExpose the Criterion Schema

Create (or update the existing) the Setting `fc.rubix.order.sourcing.criteria.custom` with your new Criterion schema, similar to Conditions.
Schema Autogeneration
Sourcing Criteria support annotation-driven generation of the Setting JSON.
How it works
  • The generator scans all classes registered in `SourcingCriteriaTypeRegistry`.
  • Reads `@SourcingCriterionInfo` + `@SourcingCriterionParam` annotations
  • Produces a complete JSON (name, type, tags, params, including select options)
Run it
  • Command: `java -jar <path>util-sourcing-<version>-sources.jar`
  • Output: SourcingCriteriaSetting.json in the same folder as the JAR/classes
  • Use this JSON to populate `fc.rubix.order.sourcing.criteria.custom` Setting
When to use
  • Any time you add/update Sourcing Criteria or their `params` - regenerate to keep UI configs in sync

Step arrow right iconVerify the Criterion Behavior

  • Use the Sourcing Profile GraphQL API to add the new Criterion to a Sourcing Strategy. 
  • Test against different Sourcing Requests and confirm the expected outcomes.