Script.apex

  • Docs
  • Tutorials
Docs Menu
  • Evaluation
  • Parsing

Evaluation Guide

Evaluation

Simple Evaluation

Simple expressions can be passed directly to evaluate them.

Object result = ScriptEngine.getInstance().eval('1 + 2 * (3 - 1)');

Context Evaluation

We can also pass in a context with variables to evaluate the expression.

Map context = new Map{
    'a' => 1,
    'b' => 2
};
Object result = ScriptEngine.getInstance().eval('a + b', context);

Limitations

Assignment expressions and function invocations are not supported in evaluation of JavaScript expressions.

Contribute on Github! Edit this section.