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

Help with JavaScript formula

Avatar

Level 1

I am working on what I thought would be a simple formula to determine a percentage. I keep running into what I believe is a divide by 0 error. The message reads " The value entered does not match the format of the field [Meeting attendance percentage]". Because I am unframiliar with writing JavaScript I need help resolving this issue. If someone could please help with my formula I would appreciate it. I have tried changing the format from number to none and that did nto seem to fix the problem.

Here is my JavaScript

var a=this.getField("Number of meetings during period");
var b=this.getField("Number of meetings attended during period");
event.value=(b.value/a.value)

Thank you so much for your help.

0 Replies

Avatar

Level 6
Try this variation in your event.value code

var v1 = +getField("numerator").value;
var v2 = +getField("demoninator").value;

event.value = (v2 !== 0) ? (v1 / v2) : "";

This code assumes the input fields have a numeric format type. You
would replace "numerator" and "demoninator" in the code above with the
names of your fields.