Custom field that can evaluate mathematical expressions

  • 4
  • Idea
  • Updated 2 years ago
  • (Edited)
I was tasked with making a small quality of life change to our org that would make entering expressions or big data easier on our users, and after some tinkering, I came up with a field renderer that does just that.

This snippet leverages the really awesome math.js library to allow you to enter complex expressions into any field it's assigned to, and with a key press (currently Tab or Enter, but it's easily changed), evaluates the current expression if it's valid. The snippet will keep track of what you enter and let you know what is and isn't considered a valid expression.

Because the snippet uses math.js, it can evaluate anything the library can. This includes powerful stuff like complex expressions involving BEDMAS, or matrix math, and extends to obscure but really cool stuff like unit conversion.

The snippet signifies fields it's attached by sticking a small calculator icon on it, which pulls its color from the Skuid theme currently in use.

Installation & Demo





Please visit https://github.com/mBlazonry/mBlazonrySupport  for installation instructions, 
updated instructions, new versions of this and other snippets! :D
Photo of mB Remi Gelinas

mB Remi Gelinas

  • 374 Points 250 badge 2x thumb
  • excited

Posted 2 years ago

  • 4
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
Wow!
Photo of Karen Waldschmitt

Karen Waldschmitt, Official Rep

  • 8,240 Points 5k badge 2x thumb
Remi~

Very neat. Thanks for sharing!!!

Karen