Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

I need to calculate a field based on calculated field of Age (based on birthdate)

Community Beginner ,
Feb 10, 2023 Feb 10, 2023

I'm very new to Java and not sure how to go about creating this calculated field.  I think I need to use an array but not sure.  

 

Ultimately, I need this field to get the age from "CalculatedAge", look in a table, pull the rate needed and put into the formula:  event.value=((((this.getField("EEVLife").value/1000)*Rate)*12)/26)

 

Any suggestions?

TOPICS
How to , JavaScript , PDF forms
1.2K
Translate
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
1 ACCEPTED SOLUTION
Community Expert ,
Feb 10, 2023 Feb 10, 2023

You can do it like this:

 

var age = Number(this.getField("CalculatedAge").valueAsString);
var rate = 0;
if (age<10) rate = 0.2;
else if (age<=25) rate = 0.25;
else if (age<=35) rate = 0.5; // etc.

event.value=((((this.getField("EEVLife").value/1000)*rate)*12)/26)

View solution in original post

Translate
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
Community Expert ,
Feb 10, 2023 Feb 10, 2023

You can do it like this:

 

var age = Number(this.getField("CalculatedAge").valueAsString);
var rate = 0;
if (age<10) rate = 0.2;
else if (age<=25) rate = 0.25;
else if (age<=35) rate = 0.5; // etc.

event.value=((((this.getField("EEVLife").value/1000)*rate)*12)/26)
Translate
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
Community Beginner ,
Feb 10, 2023 Feb 10, 2023

Thank you, going to try that now!!!!

Translate
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
Community Beginner ,
Feb 10, 2023 Feb 10, 2023

this is what I tried and getting a syntax error:

 

Nancy283408177mic_0-1676050860714.png

What did I do wrong?

Translate
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
Community Expert ,
Feb 10, 2023 Feb 10, 2023

Use " at begin and end of field name.

Translate
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
Community Beginner ,
Feb 10, 2023 Feb 10, 2023

Thank you, I see that now.  YOu are awesome!  

Translate
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
Community Beginner ,
Feb 10, 2023 Feb 10, 2023
LATEST

Worked like a charm!   Thanks again.

Translate
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