Business Rules & Calculations

Choose the right tool for business rules and calculations in Rossum: use Rossum Rules for validation logic and formula fields for computed values.

Rossum platform allows you to define both rules and calculations in many different ways. This guide aims to describe the tradeoffs involved and, based on those, what the best practices are.

For the purposes of this best practices guide, rules and calculations are understood as:

Note:

Functionality that displays information to the user on the annotation screen (e.g., an error message when a check fails).

Note:

Functionality that takes inputs and returns an output value or modifies a value in place (e.g., VAT number normalization).

How to Write Business Rules

  • Rossum’s recommended way to write business rules is to use functionality called Rossum Rules:

    • Automatic dependency resolution: if another field needs to be computed first, the rule will wait for the computation.

    • Optimized evaluation: runs only when it needs to.

  • If using SF for rules, you must set the SF to run on initialize, started, and updated. Otherwise, the rules may not always be triggered and your validation will have gaps.

  • Do not combine calculations and rules; it is almost always more maintainable to first run calculations and then trigger a rule based on the result.

  • Do not write rules in formula fields.

How to Write Calculations

  • Rossum’s recommended way to write calculations is to use formula fields:

    • Automatic dependency resolution: if another field needs to be computed first, the rule will wait for the computation.

    • Optimized evaluation: runs only when it needs to.

Summary

  • For most cases, using Rossum Rules is the best way to write business rules. The same applies to formula fields for writing calculations.

  • There are situations where using a serverless function is more suitable. Such situations include:

    • You have long or complicated code:

      • Formula fields have a limit of 2000 characters.

      • Some functionality needs to be run on the document level, not on the level of individual fields.

    • You need to manually control the order of evaluation.