Capture App update: Announcing a unified rule engine in v42

Dear DHIS2 community,

As part of our ongoing effort to unify program rule evaluation across DHIS2, the web Capture App is now adopting the shared Kotlin-based rule engine already used by the Android App and backend API. This change ensures that program rules behave consistently across web, Android, and server-side environments, making Tracker/Event implementations easier to maintain.

This change could affect your configuration because it removes support for legacy JavaScript-style expressions used in program rules, replacing them with a structured expression parser. Rules that depend on unsupported logic may silently fail or produce incorrect results. The new engine requires expressions to use the supported DHIS2 expression language.

How do I review my configuration?

1. Compile your program rules and Identify unsupported/deprecated logic

Make an inventory of all program rules used in your Tracker or Event programs and identify any logic patterns that use JavaScript-style constructs.

Below is a summary of common JavaScript expressions, with examples of how to rewrite them using supported syntax:

Logic Area Previous parser (41 and below) Kotlin compatible expression Notes
String concatenation #{firstName} + ’ ’ + #{lastName} d2:concatenate(#{firstName}, ’ ', #{lastName}) + not allowed for concatenating strings
Negation !#{firstName} #{firstName} == false JavaScript-style negation is invalid for all value types including booleans
Strings in expression box (Assign value) Hello “Hello” or ‘Hello’ Strings must be single or double quoted in the expression box
Variable quoting in functions d2:hasValue(‘firstName’) d2:hasValue(#{firstName}) Remove quotes from variables in functions

2. Update your program rules configuration … if needed

Rewrite any unsupported logic using the supported expression language.

3. Document your changes

Update internal SOPs, configuration guides, and training materials and inform trainers and supervisors of the behavior change.

Testing in your current version

You can toggle the new rule engine on version 41 or 40 (experimental) as long as you have the Capture 101.33.00 or newer version.

To toggle rule engine:

  1. As system user, open the DataStore Management App
  2. Click on capture namespace
  3. If a Key named ruleEngine does not exist already , create it first by clicking on + New Key button and entering ruleEngine and Add . If it already exists, head to the next step.
  4. Click on key ruleEngine and on the right hand pane, change the empty {} into {"version" : "new"}
  5. If you want to toggle back to the old rule engine, simply change the above value into {"version" : "old"}

Useful resources

For more detailed guidance on configuring program rules, supported functions, and migrating to the Kotlin Rule Engine, the following resources may be helpful:

We want to hear from you!

We know program rules are used in creative and diverse ways across DHIS2 implementations. Please reply in this thread or add a ticket in Jira if you:

  • Have rules that broke or now behave differently
  • Encounter issues when testing your programs in version 42
  • Are unsure how to rewrite a specific expression

Your feedback helps improve documentation, guides, and support for other implementers going through the same transition.

Thank you for being part of the DHIS2 community and helping make the platform stronger for everyone.

— The DHIS2 Core Team


  1. Both Web and Android work equally now but you can still find the documentation within each of their docs. ↩︎

6 Likes

Thank @nancyesp you for the tips. Many tracker implementations remain on the old Tracker Capture due to compatibility issues—likely caused by those changes. I’m currently reviewing a program that has over 200 program rules.

3 Likes

any chance to make script/screen that could report these problem ?

worked on a taskr script : check bad expression for rule engine migration · GitHub

It has some false positive but helps a bit…
Can you provide a list of fields that may contain expression ?
currently only checking “condition” and program rule actions “data”

to see it in action : Login app | DHIS2

1 Like

Hi @Stephan_Mestach,

To confirm, the only two places in program rules that contain expressions are the condition and the text box that is labelled as “Expression to evaluate and display after static text” in the UI (data in program rule action)

Thank you for sharing.

1 Like