Math and Function Node

In our use case, we allow end users to create their own formula for transposing readings coming in from a device into the unit of measure they want to see. For instance, our device can measure milliamps 0 - 24. This device can be set up to monitor a tank of water with a pump attached. The user can create a formula to transpose the reading of say 7 milliamps from the device, into feet of water that is in the tank.

Why can’t the workflow evaluate a string formula? The Math node can’t do it, and the Function node, which is supposed to support JavaScript can’t even run the eval(string) function.

How do I get a string (“5 * 2.1625 - 8.65”) to evaluate in a workflow?

Hi @Jonathan_Betke,

The platform’s current functionality does not support evaluating a string formula. I will make a feature request with our engineers, and follow up with any ideas we may come up with to solve this problem.

Thanks!
Julia

@Jonathan_Betke,

One crazy idea I just had. You might be able to use something like this:

It’s a library that allows you to create a JSON representation of logic. Being that’s its JSON, you could evaluate it within the workflow engine. Overall, depending on complex the customers’ logic is, you may be able to come up with your own standard. But, this may be a lot of work to solve a simple problem.

Anyway, just letting you know the idea I had. Now that we have the feature in the system we may come up with the right way of doing it in the future.

Hey,

Any progress on this feature, in our use case, we encounter the same problem, to evaluate a string as an expression.

Hi,

I used this code, which allows to perform basic operations and implemented a custom node to Evaluates the result of the String arithmetical expression.

I share here the nodes that can be useful.

calc-develop.flow (10.9 KB)
matheval-develop (1).node (7.0 KB)

@Vander_Maziero,

Thank you so much for sharing your flow and node with the community!

I did make a new feature request for this feature, so I will be sure to follow up with you as I learn more about it from our engineering team.

Thank you,
Heath

1 Like

Hello @Vander_Maziero,

I wanted to reach out to you and mention that we did just release a new Format Helper called evalExpression, which evaluates a string as an expression.

You can check it out in the documentation I’ve linked, and you can find out more about our latest release in our blog.

Thanks,
Heath

1 Like