Skip to main content
Known Participant
February 10, 2023
Answered

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

  • February 10, 2023
  • 1 reply
  • 1422 views

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?

This topic has been closed for replies.
Correct answer try67

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)

1 reply

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
February 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)
Known Participant
February 10, 2023

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

Known Participant
February 10, 2023

Use " at begin and end of field name.


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