Help with Custom Calculation Script

New Here ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

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!

 

 

 

TOPICS
Windows

Views

134

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Most Valuable Participant , Feb 16, 2021 Feb 16, 2021
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;

Likes

translate

Translate

Translate
Most Valuable Participant ,
Feb 15, 2021 Feb 15, 2021

Copy link to clipboard

Copied

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

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2021 Feb 16, 2021

Copy link to clipboard

Copied

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.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Feb 16, 2021 Feb 16, 2021

Copy link to clipboard

Copied

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;

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2021 Feb 16, 2021

Copy link to clipboard

Copied

Thank you!  Sadly it didn't work .. am I doing something wrong?

default8ylk0t09g43s_0-1613488056177.png

Screen2.PNG

 

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Feb 16, 2021 Feb 16, 2021

Copy link to clipboard

Copied

Yes, you've not placed it under the correct location. Read my reply more carefully, please.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 16, 2021 Feb 16, 2021

Copy link to clipboard

Copied

Thank you .. it works!!  I am very appreciative!!

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 16, 2021 Feb 16, 2021

Copy link to clipboard

Copied

 

Reason I asked you in other post, what do you want  if MGMT field is blank, because  this type of code will show 0 in C_M when MGMT is 0 but it will also show 0 in C_M if MGMT is blank,if it doesn't bother you that way thats ok, but i think it would be better to make C_M blank when MGMT is blank.

Also this will just replicate whatever number is in MGMT field,you should make it to not show calculation until both fields have values.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines