Fluent Commerce Logo
Docs

Create Custom Sourcing Criterion

How-to Guide

Author:

Kirill Gaiduk

Changed on:

26 Sept 2025

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’s “lower is better” (e.g., distance)
1@SourcingCriterionInfo(
2    name = "mySourcingCriterion",
3    type = "company.sourcing.criterion.my",
4    tags = { "ATS-agnostic" } // or "ATS-dependent", "Exclusion"
5)
6public class MySourcingCriterion extends BaseSourcingCriterion {
7
8    @SourcingCriterionParam(name = "value", component = "integer")
9    private Integer threshold;
10
11    @Override
12    public void parseParams(final JsonNode params) {
13        // parse threshold, lists, units, etc.
14    }
15
16    @Override
17    protected float execute(final SourcingCriteriaUtils.CriterionContext ctx) {
18        // Return:
19        //  -1f to exclude a location,
20        //   0..1f (or any float) to score/rank a location.
21        return 0.75f;
22    }
23
24    // Override normalize(...) only if the default doesn’t fit your scale
25}

Step arrow right iconRegister the Criterion in the Type Registry

Register a unique `type` with `SourcingCriteriaTypeRegistry`.

1static {    SourcingCriteriaTypeRegistry.register("company.sourcing.criterion.my", new MySourcingCriterion());}

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.