*{!Formula Evaluator}* - _({!EvaluateFormula_APEX})_ - {!Evaluator crashes if custom field name contains a number}
Steps to reproduce
Steps to reproduce the behavior:
- Add a custom field to an object like Account which contains a numeric, e.g. 'Period_01'
- Using the Formula Builder screen component, create a formula to be evaluated which looks at that custom field, e.g.
IF ($Account.Period_01__c > 1, 123, 456)
- Test the output from the Formula Builder in the 'Evaluate Formula' invocable action
- Invocable action will fail with an error
Expected behaviour
Period_01__c should be recognised as a valid field on the object.
Actual behaviour
Error message in the Flow indicates the numerics in the field name are not handled, flow will crash with an error like:
An Apex error occurred: System.QueryException: No such column 'Period_' on entity 'Account'
Looking at the source code on GitHub, I believe the REGEX pattern matcher for field names is too restrictive, and only considers A-z , periods (.) and underscores (_) as valid characters in a field name.
This should be enhanced so that numbers are also valid in the context of a field name
i.e. Current pattern:
Pattern mPattern = pattern.compile('(?<!")[$!{]{1,2}[A-z_.]*[}]{0,}');
Perhaps should be:
Pattern mPattern = Pattern.compile('(?<!")[$!{]{1,2}[A-Za-z0-9_.]+(__c)?');