Skip to main content
Participant
Feb 15, 2021 7:10 PM UTC
Answered

Help with Custom Calculation Script

Very new to this so appreciate the assistance!

 

My form  has three subtotal fields

 

COREPOINTS

MGMTPOINTS

C_MPOINTS

 

If the MGMT POINTS field is 0, would like the C_M field to be 0.

 

If the MGMT POINTS field has a value, would like the C_M field to reflect COREPOINTS + MGMTPOINTS.

 

Thank you!

 

 

 

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Feb 16, 2021 2:49 PM UTC

As the custom calculation script of "C_M" (or "C_MPOINTS"... Again, you've used both names), enter the following:

 

var v1 = Number(this.getField("MGMTPOINTS").valueAsString);

var v2 = Number(this.getField("COREPOINTS ").valueAsString);

event.value = (v1==0) ? 0 : v1+v2;

8 replies

try67
Community Expert
Community Expert
Feb 15, 2021 10:27 PM UTC

Is there a space between "MGMT" and "POINTS", or not?

Translate
Participant
Feb 16, 2021 1:50 PM UTC

Apologizes - typo on my part! Thank you..

 

Subtotal Field 1 named COREPOINTS

Subtotal Field 2 named MGMTPOINTS

Subtotal Field 3 named C_MPOINTS

 

If the MGMTPOINTS field is 0, would like the C_M field to be 0.

 

If the MGMTPOINTS field has a value, would like the C_M field to reflect the total of  COREPOINTS + MGMTPOINTS.

Translate
try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
Feb 16, 2021 2:49 PM UTC

As the custom calculation script of "C_M" (or "C_MPOINTS"... Again, you've used both names), enter the following:

 

var v1 = Number(this.getField("MGMTPOINTS").valueAsString);

var v2 = Number(this.getField("COREPOINTS ").valueAsString);

event.value = (v1==0) ? 0 : v1+v2;

Translate