Skip to main content
cojelon1
Inspiring
September 4, 2025
Question

Operation into javascript

  • September 4, 2025
  • 3 replies
  • 127 views

I am trying to convert this operation into a javascript that does not give me an error message thank you.

((NewValue - OriginalValue) / OriginalValue)

3 replies

Nesa Nurani
Community Expert
Community Expert
September 5, 2025

Before calculating check that 'OriginalValue' is not zero, because you can't divide by zero, something like this  as custom calculation script (not SFN) :

var orgVal = Number(this.getField("OriginalValue").valueAsString);
var newVal = Number(this.getField("NewValue").valueAsString);

if(orgVal == 0)
 event.value = "";
else
 event.value = (newVal-orgVal)/orgVal;
PDF Automation Station
Community Expert
Community Expert
September 5, 2025

What is the error message?

creative explorer
Community Expert
Community Expert
September 5, 2025

@cojelon1 sorry, what are trying to 'convert this operation into a javascript' — a form?

m