You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the introduction of the FormulaEval namespace (available in developer preview for Spring 24 release), Salesforce will enable us to define formulas as strings and dynamically express values with these formulas.
The Trigger Actions metadata within the framework should support these formulas to define an optional entry criteria for the actions.
globalclassTriggerActionRecord {
globalSObjectrecord; // new version of the record in the DML operationgloablSObjectrecordPrior; // old version of the record in the DML operation
}
For example, if we wanted a trigger action to execute only if the Description has been changed and now contains the string "Now take action", then we would define the entry criteria as such: Trigger_Action__mdt.Entry_Criteria__c
CONTAINS(record.Description, "Now take action") && (record.Description <> recordPrior.Description)
When the DML operation occurs, the system will create instances of TriggerActionRecord from the contents of Trigger.new and Trigger.old, then check them against the criteria formula.
If the formula evaluates to true, then the records will be filtered into the newList and oldList which will be passed into the Trigger Action class.
If no records evaluate to true, there will be no dynamic instantiation of the trigger action.
The text was updated successfully, but these errors were encountered:
The main advantage would be visibility of entry criteria from the metadata record itself without having to open the apex class.
The second benefit would be to help with the trigger action flow recursion depth issue that is explained here:
With the introduction of the FormulaEval namespace (available in developer preview for Spring 24 release), Salesforce will enable us to define formulas as strings and dynamically express values with these formulas.
The Trigger Actions metadata within the framework should support these formulas to define an optional entry criteria for the actions.
For example, if we wanted a trigger action to execute only if the
Description
has been changed and now contains the string "Now take action", then we would define the entry criteria as such:Trigger_Action__mdt.Entry_Criteria__c
When the DML operation occurs, the system will create instances of
TriggerActionRecord
from the contents ofTrigger.new
andTrigger.old
, then check them against the criteria formula.If the formula evaluates to true, then the records will be filtered into the
newList
andoldList
which will be passed into the Trigger Action class.If no records evaluate to true, there will be no dynamic instantiation of the trigger action.
The text was updated successfully, but these errors were encountered: