Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*{!Formula Evaluator}* - _({!EvaluateFormula_APEX})_ - {!Evaluator crashes if custom field name contains a number} #1576

Open
cdevelin opened this issue Sep 2, 2024 · 0 comments

Comments

@cdevelin
Copy link

cdevelin commented Sep 2, 2024

Steps to reproduce

Steps to reproduce the behavior:

  1. Add a custom field to an object like Account which contains a numeric, e.g. 'Period_01'
  2. 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)

  1. Test the output from the Formula Builder in the 'Evaluate Formula' invocable action
  2. 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)?');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant