Copy link to clipboard
Copied
I have two fields, field A and field B. Field A needs to be divided by Field B and the answer needs to be rounded up. Example: 2÷5=1
How can I code this?
var AA = this.getField(“UNITSWEEK”).value;
var BB = this.getField(“MAXDAYSWK”).value;
if (BB==0) event.value = "";
else event.value = Math.ceil (AA / BB);
}
Copy link to clipboard
Copied
Did you use the code? Any problem with this?
Copy link to clipboard
Copied
No, I cannot get it to work yet. Have any ideas?
Copy link to clipboard
Copied
Any error message? Where does you place the code?
Copy link to clipboard
Copied
I changed it to this under custom calculations:
var AA = this.getField(“UNITSWEEK”).value;
var BB = this.getField(“MAXDAYSWK”).value;
event.value = "";
if(Number(BB) != 0) {
event.value = AA / BB;
event.value = Math.ceil(event.value);
}
It accepts the code, but it is not functioning.
Copy link to clipboard
Copied
Check the field calculation order.
Copy link to clipboard
Copied
The field calculation order is correct.
Copy link to clipboard
Copied
I have no more idea.
Copy link to clipboard
Copied
If you've used the code you posted above it will not be accepted as it contains invalid quotation marks in the first two lines, so either what you posted is not the actual code you entered, or the code you entered was not actually accepted.