Skip to main content
Known Participant
January 4, 2017
Answered

I have the following formula in a form "this.getField("Thickness")/Math.cos(this.getField("TransducerAngle")). I am trying to calculate T/cosine(X degrees) where T is the Thickness and X is the Angle. this is my best effort at it but it is not work

  • January 4, 2017
  • 1 reply
  • 615 views

I have the following formula in a form "this.getField("Thickness")/Math.cos(this.getField("TransducerAngle")).  I am trying to calculate T/cosine(X degrees) where T is the Thickness and X is the Angle.  this is my best effort at it but it is not working.

This topic has been closed for replies.
Correct answer George_Johnson

You will need to correctly convert the value in degrees to radians to use the Math.cos method. Also, check the JavaScript console (Ctrl + J) to see if any error are reported. Finally, since the denominator could conceivably be zero (or very close), you should not perform the division if it is and set the field value to something else, perhaps blank.

1 reply

Joel Geraci
Community Expert
Community Expert
January 4, 2017

You're only getting the field object, not the value of the field. Try..

this.getField("Thickness").value/Math.cos(this.getField("TransducerAngle").value)

Known Participant
January 4, 2017

Joel

Thanks for your reply I tried it but it is not returning a value.

George_JohnsonCorrect answer
Inspiring
January 4, 2017

You will need to correctly convert the value in degrees to radians to use the Math.cos method. Also, check the JavaScript console (Ctrl + J) to see if any error are reported. Finally, since the denominator could conceivably be zero (or very close), you should not perform the division if it is and set the field value to something else, perhaps blank.