Expression

🎯 Purpose

An Expression is used to filter clients participating in a campaign. It is a script written in JavaScript or Python that evaluates a specific client's data and returns true or false. Only clients for whom the result is true will be included in the campaign execution.


βš™οΈ Using the JavaScript/Python Engine

The timveroOS platform supports script execution in both JavaScript and Python via the ScriptManager component.

The CampaignExecutionServicearrow-up-right compiles the expression with:

Script script = scriptManager.compile(expression);

And evaluates it for each client with:

Object evaluationResult = script.eval(Map.of("client", client));

πŸ’‘ The script runs in a sandboxed environment with no access to unsafe resources. Compilation or runtime errors are wrapped in a ScriptException and logged.


πŸ” Security

Scripts are executed with strict limitations:

  • Restricted classes

  • Execution timeouts

  • No external system access

Any error (e.g., NullPointerException, syntax error) is captured in an ExceptionEntity and shown in the UI as EXCEPTION_OCCURRED.


πŸ§ͺ Expression Example

This expression selects clients who are:

  • Older than 25

  • Have an income over 3000

  • Live in the United Kingdom


πŸ“Œ Code Usage Example

Last updated

Was this helpful?