3

I have a requiremnt where a mathematical expression is embedded in an apex string variable and I need to evaluate that expression value. Is there any way to do this? Any workaround for this? Thanks in advance.

4
1

No, apex does not have a way to evaluate a string at runtime. You could write your own parser, but it wouldn't be easy. You'd have to find a way to do this in JavaScript if your logic has any sort of UI/page layer.

Here are a few examples from questions asked here previously: Evaluate expressions/conditions in apex code ? (which are stored in string/text)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.