Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Need help with a script

jeanette614
Level 4
Level 4

I am very inexperienced at scripting but I need a script to show a zero if a number goes negative.  So what I have is:

$.rawValue = X - Y

But I need rawValue to never show a negative number, only a zero when that value becomes a negative. Otherwise, show the value.

Please help.

3 Replies
Srini_Dhulipall
Level 10
Level 10

You can use the following script to display ZERO instead of negative numbers.

var FinalValue = X-Y;


if(FinalValue<0) then
$.rawValue = 0;
else
$.rawValue = FinalValue;
endif

Thanks

Srini

jeanette614
Level 4
Level 4

That seems like it should work but alas, it doesn't. Nothing shows in the field at all. Not even the negative numbers like I had before.

Srini_Dhulipall
Level 10
Level 10

Then the problem might be the language.. Set the scripting language to FormCalc instead of JavaScript in the Script editor. You can find it in the right had top corner in the Script editor.

Which event are you writing the code?

Thanks

Srini