MIN and MAX work on numbers but throw a runtime error on dates.
Repro
expression.Evaluator.run('MIN([3, 1, 2])', someId); // => 1
expression.Evaluator.run('MIN([DATE(2026,1,1), DATE(2026,2,1)])', someId); // runtime error
expression.Evaluator.run('MAX([DATE(2026,1,1), DATE(2026,2,1)])', someId); // runtime error
Expected: the earliest / latest date.
Actual: a runtime error with an empty message.
Why it matters
"Earliest" and "latest" over a set of child records is one of the most common things a document or
formula wants to say — first activity, last payment, next due date:
Tasks -> MAP(ActivityDate) then the earliest of those
The workaround is -> SORT(ActivityDate) -> MAP(ActivityDate) -> FIRST(), which works but is
obscure, and SORT + FIRST are doing a job MIN already names.
Environment
Expression 1.52.0.1, Developer Edition scratch org.
MINandMAXwork on numbers but throw a runtime error on dates.Repro
Expected: the earliest / latest date.
Actual: a runtime error with an empty message.
Why it matters
"Earliest" and "latest" over a set of child records is one of the most common things a document or
formula wants to say — first activity, last payment, next due date:
The workaround is
-> SORT(ActivityDate) -> MAP(ActivityDate) -> FIRST(), which works but isobscure, and
SORT+FIRSTare doing a jobMINalready names.Environment
Expression 1.52.0.1, Developer Edition scratch org.