Skip to main content
Participating Frequently
October 20, 2025
Question

Need someone to create custom calculation script PLEASE

  • October 20, 2025
  • 1 reply
  • 154 views

I have the following fields:

"New Construction or Addition" (let's call it Field 1)

"Undefined_2" (let's call it Field 2)

 

When someone puts a whole number into Field 1 I need that muliplied by .60 and the result will show up in Field 2 as an amount with two decimal places.  However, if Field 2 is less than 600 then Field 2 needs to then say 600 with no decimal places.

 

I am very new to scripts so any help would be much appreciated.

 

Thank you!

1 reply

Nesa Nurani
Community Expert
Community Expert
October 21, 2025

Try this as custom calculation script of field 2:

var f1 = this.getField("New Construction or Addition").value;

if (/^[1-9]\d*$/.test(f1)) {
 var num = Number(f1);
 var result = num * 0.60;
 if (result < 600) {
  event.value = 600;} 
 else {
  event.value = result.toFixed(2);}} 
else {
 event.value = "";}
Participating Frequently
October 21, 2025

Thanks, that worked!  However, I also have a line below that that needs to be the sum of this final value plus some others.  When I tell this sum line to add the sum of field 2 it always shows it as 600 even if the resulting number is higher than 600.  Any thoughts?

Participating Frequently
October 21, 2025

Actually the sum line I have below is acting differently than what I said.  If the amount in field 1 is 1004 then field 2 results in 602.40 which is correct.  But when I create a field below that takes the sum of field 2 it lists it as 601.80.  Any ideas why?