0

EDIT:

I am sorry for the poor description. I tried editing it to make it more clear.

I have an API that will accept several parameters. At the moment I need to perform a math operation using those parameters like so:

a / b * c * d

Where "a", "b", "c" and "d" will be values being passed to the API. However I want to make the math operations configurable using custom metadata. This way if a change needs to happen in the future no code will have to be changed only custom metadata.

Can I use custom metadata to make the formula flexible to the point where if needed tomorrow it can change to:

a * b / d
7
  • I don't really understand what your asking. Your formula is part of your metadata, and is customizable - why would you add another layer to that when you can already change it on the drop of a hat to a different value? – battery.cord Apr 30 '18 at 19:49
  • Additionally, by "Custom Metadata", do you mean Custom metadata types ? – battery.cord Apr 30 '18 at 19:50
  • Are you speaking more generally about being able to modify a given algorithm based on data provided by custom metadata record(s)? – pchittum Apr 30 '18 at 20:08
  • 3
    You could write a recursive-descent parser in Apex, but that seems like overkill. There's no eval() you can call, though, so you may not have a lot of options. – David Reed Apr 30 '18 at 20:35
  • 1
    Are you passing along the operations from apex? If not, nothing you do in salesforce will matter for determining this operation. If you're already passing these values, great, adjust your calling code. If anything, I would recommend passing along some json form of your operators + values and hope whatever language the api is in can call eval(), otherwise you're probably out of luck. – battery.cord Apr 30 '18 at 20:58

Your Answer

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

Browse other questions tagged or ask your own question.