🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
OCLOperators scriptevalcheck
Created by Hans.karlsen on 2022-03-30 · Last edited by Vale.buyondo on 2026-02-24.

See: OCLOperators_scripteval

ScriptEvalCheck is a validation operator used in the Executable Action Language (EAL). It parses a string as OCL and verifies its syntax and type-compatibility against a specific model context without actually executing the logic or changing data.

Syntax

self.ScriptEvalCheck(IsQuery: Boolean, ReturnType: Type, Expression: String): String

  • IsQuery: Set to false for standard actions or true for read-only evaluations.
  • ReturnType: The expected model type (e.g., Decimal, String, Integer) that the expression must return.
  • Expression: The String attribute or literal containing the OCL code.

1. Implementation Logic

In your Action Editor, you implement ScriptEvalCheck as the condition in a let statement. This allows you to store the "check result" as a variable before deciding whether to proceed with the actual evaluation.

Action OCL Syntax:

Object Constraint Language

-- 'validationInfo' will hold the result of the check
let validationInfo = self.ScriptEvalCheck(false, Decimal, self.DynamicFormula) in
(
  -- If the script is valid, 'validationInfo' is exactly 'ok'
  if validationInfo = 'ok' then
     -- SAFE TO EXECUTE
     self.FormulaResult := self.ScriptEval(false, Decimal, self.DynamicFormula).asstring
  else
     -- UNSAFE: Store the error message so the user can see what's wrong
     self.FormulaResult := validationInfo
  endif
)

2. How it Works

When you call ScriptEvalCheck, MDriven performs three background tasks:

  • Syntax Scan: It checks if the string in self.DynamicFormula is valid OCL (e.g., no missing brackets or misspelled operators).
  • Type Verification: It ensures the script returns the type you requested (in our case, Decimal).
  • Context Check: It confirms that all properties referenced (like self.Total) exist on the Order class.
Documentation OCLOperators scriptevalcheck 1771913116747.png
Documentation OCLOperators scriptevalcheck 1771913164431.png

3. Visualizing Failure vs. Success

Implementing this operator is what created the "Work Visualization" we saw in your screenshots:

  • Failure Implementation: When the formula was 'self.Total * 0.10', ScriptEvalCheck identified a type mismatch between Decimal and Double. It returned a long error string, which you successfully displayed in the FormulaResult box.
  • Success Implementation: When you corrected the formula to 'self.Total * 0.10.ToDecimal', ScriptEvalCheck found no issues and returned the string 'ok'. This allowed the if statement to trigger the actual ScriptEval.