Skip to main content
N8-K
Participating Frequently
July 30, 2018
Answered

Hide calculations displaying 0, NaN, or Infinity

  • July 30, 2018
  • 1 reply
  • 3216 views

I'm trying to hide all calculations displaying 0, NaN, or Infinity. I've tried the following, but the field is still displaying:

if (aType == " " || (event.value == Infinity) || isNaN(event.value)) {

  event.value = "";

Any suggestions?

This topic has been closed for replies.
Correct answer try67

Okay, looks like console.printIn(); saved the day again. I was not accounting for a simple blank value which is what I was getting. I added (event.value == "") to my conditions and now it works as expected:

if ((event.value == "") || (event.value == Infinity) || isNaN(event.value)) {

  event.value = "";

Still, I appreciate the reply and inspiration that I was on the right track!


That should not have changed anything... If the value is already an empty string then setting it to be an empty string won't change anything in it.

1 reply

try67
Community Expert
Community Expert
July 30, 2018

- Where did you place this code?

- What's "aType"?

- Why are you getting such results in the first place? It would be better to adjust the way the calculations are performed to prevent it from happening.

N8-K
N8-KAuthor
Participating Frequently
July 30, 2018

- The code was placed in the field's Calculate > Custom calculation script area

- Apologies, I should have left that part off; "aType" (Action Type dropdown field) is not particularly relevant to the issue. I should have just shown:

if ((event.value == Infinity) || isNaN(event.value)) {

  event.value = "";

- The calculations I'm performing are sound and work unless the values feeding the calculation are blank. I'm simply trying to show nothing until all the pertinent values are available.

try67
Community Expert
Community Expert
July 30, 2018

I think your code should work, then... Does it not?