Skip to main content
Known Participant
Apr 21, 2019 12:57 PM UTC
Question

Having trouble with the Math.floor command

Hi all,

I know I am missing something, but can't quite figure out what. I am just trying to round a field down using the math.floor command I am certain I have the syntax wrong somewhere. Here is the script the calculation is working perfectly, but it is always rounding up.

event.value = ( this.getField("resourcesRow1").value *  this.getField("g1p1multiple1").value )*.5;

event.value = math.floor("g1p1resourcestotal");

Thanks for any help.

Regards,

Larry

This topic is closed to new replies. Start a new post to keep the conversation going.

5 replies

try67
Community Expert
Community Expert
Apr 21, 2019 1:09 PM UTC

It's Math.floor(), not math.floor()... It's important to remember that JS is case-sensitive.

Translate
try67
Community Expert
Community Expert
Apr 21, 2019 1:09 PM UTC

Also, the input parameter for that method needs to be a number, not a string.

Translate
try67
Community Expert
Community Expert
Apr 21, 2019 1:10 PM UTC

Use this:

event.value = Math.floor(Number(this.getField("resourcesRow1").valueAsString) * Number(this.getField("g1p1multiple1").valueAsString) * 0.5);

Translate
Bernd Alheit
Community Expert
Community Expert
Apr 21, 2019 1:03 PM UTC

Check the console for errors.

Translate