Hi,
I am developing a small app for tennis league matches.
Every match calculates how many points are earned by winner and loser.
e.g. formula for winner is:
(gamesLost+(gameLost-gameWon)*0.2)*coeficijent
It works nice, but I need to have formula configurable through app settings (probably stored in appSettings table as a string).
As template column enables dynamic content setting from any other column, math column does not allow that.
Is there any way I can achieve wanted? (To have text formula stored in appSettings to evaluate to points won).
Would regex help here?
Thanks,
Darko
Interesting use case.
I think you could probably use the eval()
function inside a JavaScript column. Just be aware that the JavaScript column always returns a string, so you would need a math column to coerce the result to a Number.
works nice. Thank you @Darren_Murphy
Just curious, can you talk through the full setup with the eval function as Darren mentioned? Do you have a template column with the formula and reference it in the JavaScript snippet?
The latest update is : it does work only on iPhone devices, several users have reported it doesn’t work on various Android devices, so I switched back to hard coding the formula in the column.
My evaulation column is very simple : return eval(p1);
Thanks
I have a template column for formula that is being filled with real values, so the end resuls is a string e.g. 10+(20*0.3) which js evaluates to a real value. But for some reason, it doesn’t go through on Android devices and returns 0
Hola Darko,
Just a little warning using eval():
Instead of using a value with decimals to get a result, I would change it to its equivalent as a fraction in order to avoid problems with device’s regional settings.
I mean, instead of 10+(20*0.3)
, I’d use: 10+(20*3/10)

A device using Spanish as its regional setting expects a comma (“,”) as the decimal point, not a period (“.”) for example.
Feliz domingo!
3 Likes
Wow, what a catch maestro! THANKS !