Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Luckily there is a mechanism from PSL (as well as the Javascript API, documented elsewhere) to calculate and persist formula fields if you do encounter stale data problems.

Code Block
DEFAULT{
Action=CalculateSaveFormulas;
ObjectType=<ObjectAPIName>;
ObjectIds=<Optional comma-separated list of object Ids. If empty/unspecified, will operate on all records of ObjectType>;
WhereClause=<Optional WHERE clause to programmatically select specific Ids>;
FormulaFields=<Optional comma-separated list of fields.  If empty/unspecified, will operate on all formula fields of the ObjectType>;
}

For Let's say, for example, if you want to ensure that all formula fields on the Account object are always kept up-to-date in the local database, you may wish to .  You can create an OnSave PSL Validation RuleTrigger (see the next section in the wiki about PSL Validation Rules and Triggers).  The following PSL may accomplish that:

Code Block
DEFAULT{
Action=SetVar;
VarName=Account_Id;
VarValue=@@CurrentObjectId@@;
| 
Action=CalculateSaveFormulas;
ObjectType=Account;
ObjectIdObjectIds=,%%Account_Id%%;
}

WARNING: his can be an incredibly expensive operation if you do not specify any filter criteria.  In the example above, had we not specified the ObjectIds parameter, then the calculation and persistence would run on all Account records!


...

PSL Formulas

Spring 2019 NOTE: we recommend that you use SFDC Formulas going forward, but PSL formulas will continue to be supported.

...