Nebula-Consulting/nebula-core

IsLessThan to support comparison betweens 2 SObject fields

Opened this issue · 0 comments

Currently, when comparing 2 SObject fields it will throw a TypeException, see the example below:

new nebc.LazyTriggerContextPairIterator(oldList, newList)
                .filterT(new nebc.IsFieldChangedInTrigger(SObject.SomeField))
                .newRecords()
                .filterT(new nebc.IsLessThan(SObject.PercentLeft, SObject.PercentRight)) // System.TypeException
                .put(...)
                .forEach();

We can add a new constructor to IsLessThan to support this sort of comparison:

global IsLessThan(SObjectField left, SObjectField right) {
    functions = new FunctionList(new FieldFromSObject(left), new FieldFromSObject(right));
}