Skip to main content
Known Participant
March 22, 2023
Answered

Calculated fields within Adobe Form

  • March 22, 2023
  • 1 reply
  • 3761 views

All, I need some help on various parts of this form.  I have removed certain information that made it specific to a client so there is no HIPPA violation and attached the form below.  There are hidden fields:  Calculated Age (calculates the age of the employee), SpouseAge (Calculates Spouses Age), DCAge1(Calculates dependent child's age for row 1), DCAge2(calculates dependent child's age for row 2), DCAge3(calculates dependent child's age for row3), DCAge4(calculates dependent child's age for row4), DC1Rate(calculates the rate based on the DCAge1), DC2Rate(calculates the rate based on the DCAge2), DC3RAte(calculates the rate based on the DCAge3), DC4Rate(calculates the rate based on the DCAge4).  Then there are other fields that calculate using those hidden fields:  MedEERate(calculates the rate based on the employee's age), MedESRate(calculates the rate based on the Spouse's Age), MedECRate(calculates the top 3 ages rates of the dependent children), MedFAMRate(calculates the Spouse's raate, and all the top 3 ages rates of the dependent children).  

 

I am having problems with the following fields:  SpouseAge(need it to calculate the spouses age no matter what line in the dependents area it shows up on and currently I only know how to select the actual field, not a group of fields), DCAge1 through DCAge4(same as Spouse Age - I need it to calculate the ages no matter which field SPCHx=="Dependent Child" and it isn't doing that), DC1Rate through DC4Rate are not working properly(not pulling the appropriate rate for the age of the dependents.  MedEERate and MedESRate (not pulling rates according to age in "CalculatedAge" or "SpouseAge" field), MedECRAte and MedFAMRate (should be calculating the rates based on the top 3 ages of dependent children and Family should add in the rate for the spouse - they are pulling according to incorrect ages <14).

 

There is one other field to note that doesn't seem to be working correctly and that is the Voluntary Critical Illness Benefit Amount field for the Children.  It should only show up if there are dependent children noted under dependents above and it is calculating no matter what.

 

I could really use some help from some of you that really know your stuff.  Thank you

This topic has been closed for replies.
Correct answer try67

An employee can only have one spouse but the spouse would have to be indicated in one of the dependent rows.  It just isn't specific as to which row they put their spouse.  i.e., could list 3 kids then their spouse, etc.  I was assuming at first that they would automatically put them in the first row, but you can't assume they will think like that.  So, trying to cover all the bases.  There is no other spouse field.  


Try this code (I didn't check your age calculation script, by the way):

 

event.value = "";
for (var i = 1; i <= 4; i++) {
    if (this.getField("SPCH" + i).valueAsString == "Spouse") {
		var SPdobValue = this.getField("DOBRow" + i).valueAsString;
		if (SPdobValue != "") {
			var SPdob = util.scand("mm/dd/yyyy", SPdobValue);
			var today = new Date();
			var SPage = today.getFullYear() - SPdob.getFullYear();
			if (today.getMonth() < SPdob.getMonth())
				SPage = SPage - 1;
			if ((today.getMonth() == SPdob.getMonth()) && (today.getDate() < SPdob.getDate()))
				SPage -= 1;
			event.value = SPage;
		}
		break;
	}		
}

1 reply

try67
Community Expert
March 22, 2023

Nancy, if you want help with your issues please try and keep the descriptions as short and to the point as possible. You're more likely to get responses that way as it's easier for us to understand the issue without having to read large chucks of text and code. Also, when you refer to a field please provide its exact name (and preferably the page number), so we don't need to hunt for it in the entire file... For example, "Voluntary Critical Illness Benefit Amount field for the Children". Is that the "CHCI" field on page 2 of the file you shared?

Known Participant
March 22, 2023

Sorry for the length, there were just so many little issues.  Yes, the field on the second page "CHCI" is the one that is populating no matter if there are dependents listed or not.

try67
Community Expert
March 23, 2023

I'm sorry, misunderstood your question.  It should show up no matter if they have one dependent chil or multiple.


OK, then you can use this code:

 

var isDependentChild = false;
for (var i=1; i<=4; i++) {
	if (this.getField("SPCH"+i).valueAsString=="Dependent Child") {
		isDependentChild = true;
		break;
	}
}

if (isDependentChild) {
	var EEAmt=Number(this.getField("EECI").valueAsString);
	var Percent=.25;
	event.value=EEAmt*Percent;
} else event.value="";