Copy link to clipboard
Copied
The Code shows below:
var proposedInsured = [
'110. Insured Family History Has any of your parents, brothers or sisters, whether living or dead, been diagnosed with breast, colon, ovarian, rectal, or other types of cancer, heart disease, cardiomyopathy, stroke, diabetes, muscular dystrophy, Alzheimer’s di',
'111. Insured Family History Are you currently taking any medication?',
'113. Insured Height and Weight Information Has there been a weight change of more than 10 pounds (4.5 kilos) within the last 12 months?',
'114a. Insured high blood pressure, chest pain/discomfort, heart murmur, rheumatic fever, stroke, aneurysm, circulatory or heart disorder?',
'114b.Insured diabetes, sugar in the urine, thyroid or other glandular (endocrine) disorder?',
'114c. Insured kidney, bladder, or urinary disorder/infection, sexually transmitted disease, reproductive organ or prostate disorder?',
'114d. Insured disorders of the skin or pigmentation, enlarged glands or lymph nodes, nodules, polyps, cysts, lumps, tumor, mass, abnormal growth, cancer, malignancy, or any related conditions?',
'114e. Insured asthma, chronic cough, pneumonia, tuberculosis, emphysema, or any other respiratory or lung disorder?',
'114f. Insured fainting spells, convulsion, developmental delay, epilepsy, seizure, tremor, loss of consciousness, paralysis, severe headache(s) or migraine(s) or any other disorder of the brain or nervous system?',
'114g. Insured anxiety, depression, stress or any emotional/psychological, mental or psychiatric disorder?',
'114h. Insured ulcers, ulcerative colitis, intestinal bleeding, pancreatitis, hepatitis, cirrhosis, Crohn\'s disease or other disorders of the stomach, digestive organ or liver?',
'114i. Insured arthritis or systemic lupus erythematosus, gout, back or spinal disorder, joint pain, multiple sclerosis, bone fracture, muscular weakness or muscle disorder?',
'114j. Insured anemia, bleeding or blood disorder?',
'114k. Insured AIDS or positive HIV test?',
'114l. Insured any other illness or surgery?',
'115. Insured Do you have any health symptoms, recurring or persistent pains, or complaints for which a physician has not been consulted or treatment has not been received?',
'116a. Insured consulted any doctor or other health practitioner?',
'116b. Insured submitted to blood tests, ecg, x-rays, treadmill, echocardiogram, scans, MRI, ultrasounds, mammography, colonoscopy, biopsies or other tests?',
'116c. Insured attended or been admitted to any hospital or other medical facility?'
];
var proposedInsuredCounter = 0;
for (var inputField of proposedInsured) {
var field = this.getField(inputField);
if(field.value == "Y"){
proposedInsuredCounter++;
}
}
var field is null.
is there something wrong with my code that causes field to become null?
i tried showing datas from proposedInsured and i am able to do so. but when i pass data to var field, field becomes null..
Copy link to clipboard
Copied
It means there is no such field.
What exactly are you trying to achieve ?
Copy link to clipboard
Copied
there are text field named:
'110. Insured Family History Has any of your parents, brothers or sisters, whether living or dead, been diagnosed with breast, colon, ovarian, rectal, or other types of cancer, heart disease, cardiomyopathy, stroke, diabetes, muscular dystrophy, Alzheimer’s di',
'111. Insured Family History Are you currently taking any medication?',
'113. Insured Height and Weight Information Has there been a weight change of more than 10 pounds (4.5 kilos) within the last 12 months?',
'114a. Insured high blood pressure, chest pain/discomfort, heart murmur, rheumatic fever, stroke, aneurysm, circulatory or heart disorder?',
'114b.Insured diabetes, sugar in the urine, thyroid or other glandular (endocrine) disorder?',
'114c. Insured kidney, bladder, or urinary disorder/infection, sexually transmitted disease, reproductive organ or prostate disorder?',
'114d. Insured disorders of the skin or pigmentation, enlarged glands or lymph nodes, nodules, polyps, cysts, lumps, tumor, mass, abnormal growth, cancer, malignancy, or any related conditions?',
'114e. Insured asthma, chronic cough, pneumonia, tuberculosis, emphysema, or any other respiratory or lung disorder?',
'114f. Insured fainting spells, convulsion, developmental delay, epilepsy, seizure, tremor, loss of consciousness, paralysis, severe headache(s) or migraine(s) or any other disorder of the brain or nervous system?',
'114g. Insured anxiety, depression, stress or any emotional/psychological, mental or psychiatric disorder?',
'114h. Insured ulcers, ulcerative colitis, intestinal bleeding, pancreatitis, hepatitis, cirrhosis, Crohn\'s disease or other disorders of the stomach, digestive organ or liver?',
'114i. Insured arthritis or systemic lupus erythematosus, gout, back or spinal disorder, joint pain, multiple sclerosis, bone fracture, muscular weakness or muscle disorder?',
'114j. Insured anemia, bleeding or blood disorder?',
'114k. Insured AIDS or positive HIV test?',
'114l. Insured any other illness or surgery?',
'115. Insured Do you have any health symptoms, recurring or persistent pains, or complaints for which a physician has not been consulted or treatment has not been received?',
'116a. Insured consulted any doctor or other health practitioner?',
'116b. Insured submitted to blood tests, ecg, x-rays, treadmill, echocardiogram, scans, MRI, ultrasounds, mammography, colonoscopy, biopsies or other tests?',
'116c. Insured attended or been admitted to any hospital or other medical facility?'
i just want to know why it does return null instead of the field name
Copy link to clipboard
Copied
sorry, not text field but radio button. see attached photo
Copy link to clipboard
Copied
Remove backslash from field name 114h in Crohn\'s, then you can use this:
var fields = [
"110. Insured Family History Has any of your parents, brothers or sisters, whether living or dead, been diagnosed with breast, colon, ovarian, rectal, or other types of cancer, heart disease, cardiomyopathy, stroke, diabetes, muscular dystrophy, Alzheimer’s di",
"111. Insured Family History Are you currently taking any medication?",
"113. Insured Height and Weight Information Has there been a weight change of more than 10 pounds (4.5 kilos) within the last 12 months?",
"114a. Insured high blood pressure, chest pain/discomfort, heart murmur, rheumatic fever, stroke, aneurysm, circulatory or heart disorder?",
"114b.Insured diabetes, sugar in the urine, thyroid or other glandular (endocrine) disorder?",
"114c. Insured kidney, bladder, or urinary disorder/infection, sexually transmitted disease, reproductive organ or prostate disorder?",
"114d. Insured disorders of the skin or pigmentation, enlarged glands or lymph nodes, nodules, polyps, cysts, lumps, tumor, mass, abnormal growth, cancer, malignancy, or any related conditions?",
"114e. Insured asthma, chronic cough, pneumonia, tuberculosis, emphysema, or any other respiratory or lung disorder?",
"114f. Insured fainting spells, convulsion, developmental delay, epilepsy, seizure, tremor, loss of consciousness, paralysis, severe headache(s) or migraine(s) or any other disorder of the brain or nervous system?",
"114g. Insured anxiety, depression, stress or any emotional/psychological, mental or psychiatric disorder?",
"114h. Insured ulcers, ulcerative colitis, intestinal bleeding, pancreatitis, hepatitis, cirrhosis, Crohn's disease or other disorders of the stomach, digestive organ or liver?",
"114i. Insured arthritis or systemic lupus erythematosus, gout, back or spinal disorder, joint pain, multiple sclerosis, bone fracture, muscular weakness or muscle disorder?",
"114j. Insured anemia, bleeding or blood disorder?",
"114k. Insured AIDS or positive HIV test?",
"114l. Insured any other illness or surgery?",
"115. Insured Do you have any health symptoms, recurring or persistent pains, or complaints for which a physician has not been consulted or treatment has not been received?",
"116a. Insured consulted any doctor or other health practitioner?",
"116b. Insured submitted to blood tests, ecg, x-rays, treadmill, echocardiogram, scans, MRI, ultrasounds, mammography, colonoscopy, biopsies or other tests?",
"116c. Insured attended or been admitted to any hospital or other medical facility?"
];
var counter = 0;
for( var i in fields){
if(this.getField(fields[i]).valueAsString == "Y")counter++;}
event.value = counter;
Copy link to clipboard
Copied
Still encounter null
Copy link to clipboard
Copied
You need to narrow it down. Add a console.println command to the loop so you could see which field name is triggering this error. Then examine that field name VERY carefully. It must match the actual field name EXACTLY (only excluding the "#1", "#2", etc. that might appear in the Fields List panel). Even a single space being misplaced, or a single letter in upper-case instead of lower-case (or vice versa) will cause it to cause this error to happen.
Copy link to clipboard
Copied
Did you make changes to the 114h field as I suggested?
Can you share actual file with us?
Copy link to clipboard
Copied
Copy link to clipboard
Copied
There are many error messages that appear in your file whenever the value of any field is changed:
TypeError: this.getField("PolicyData.faceAmount") is null
1:Field:Calculate
TypeError: this.getField("PolicyData.amountPaid") is null
1:Field:Calculate
TypeError: this.getField("PolicyData.riders.additionalBenefits.adbAmount") is null
1:Field:Calculate
TypeError: this.getField("PolicyData.riders.additionalBenefits.cibAmount") is null
1:Field:Calculate
TypeError: this.getField("PolicyData.riders.additionalBenefits.hibAmount") is null
1:Field:Calculate
TypeError: this.getField("PolicyData.riders.additionalBenefits.fciAmount") is null
1:Field:Calculate
TypeError: this.getField("PolicyData.riders.additionalBenefits.fcmAmount") is null
1:Field:Calculate
TypeError: this.getField("PolicyData.riders.additionalBenefits.5yrctAmount") is null
1:Field:Calculate
TypeError: this.getField("PolicyData.riders.additionalBenefits.adddAmount") is null
1:Field:Calculate
TypeError: this.getField("PolicyData.riders.additionalBenefits.specifyAmount1") is null
1:Field:Calculate
TypeError: this.getField("PolicyData.riders.additionalBenefits.specifyAmount2") is null
1:Field:Calculate
TypeError: this.getField("InsuranceHistoryData.amountOfLifeInsurance1") is null
1:Field:Calculate
TypeError: this.getField("InsuranceHistoryData.amountOfLifeInsurance2") is null
1:Field:Calculate
TypeError: this.getField("InsuranceHistoryData.amountOfCriticalIllness1") is null
1:Field:Calculate
TypeError: this.getField("InsuranceHistoryData.amountOfADB1") is null
1:Field:Calculate
TypeError: this.getField("InsuranceHistoryData.amountOfADB1") is null
1:Field:Calculate
TypeError: this.getField("InsuranceHistoryData.amountOfADDD2") is null
1:Field:Calculate
TypeError: this.getField("InsuranceHistoryData.amountOfADDD1") is null
1:Field:Calculate
TypeError: this.getField("InsuranceHistoryData.amountOfCriticalIllness2") is null
1:Field:Calculate
You have to solve all of them for it to function properly.
Also, the error message that appears when the file is saved is not what you posted, but this:
SyntaxError: missing ; after for-loop initializer
524:Doc:Will Save
Copy link to clipboard
Copied
The second message is caused by lines like this one:
for (var inputField of proposedInsured) {
It should be:
for (var inputField in proposedInsured) {
Copy link to clipboard
Copied
For the calculate errors, you just need to fill up those fields.
Maybe it just shows different error message from what i see to yours (i never saw that missing ; error message). But same issue on doc 524. Ill try using in instead of of, will get back to you. Thanks
Copy link to clipboard
Copied
Filling in the fields won't solve anything. These errors are caused by an invalid field name being supplied to the getField method.
Copy link to clipboard
Copied
oops. i already fixed the field names causing the calculate error,
i also changed for (var inputField of proposedInsured) {
to
for (var inputField in proposedInsured) {
and heres the error i get:
Copy link to clipboard
Copied
also @try67 this is the original form and i just copy pasted from original to new pdf file (form fields and JS) but i doesnt work and encountered the following errors above.
clean insurance - new form
js and fillable insurance - old form (where i copy and pasted all the fields and js)
in old form it works completely but after pasting to new form JS is not working anymore
Copy link to clipboard
Copied
All the errors we pointed out are still in the old form, and there are no fields or scripts in the new one. If you copy it over you'll just be copying the errors as well.
Copy link to clipboard
Copied
if you tried to fill up just one field, the JS will work just fine. heres a sample screenshot of the old form after filling 1 field and saving.
Copy link to clipboard
Copied
No, it's not working fine. Open the JS Console and you'll see a myriad of error message. And the Will Save script is not working well, either. It doesn't get to that alert dialog for me at all.
Copy link to clipboard
Copied
Activate a checkbox at 2. Sex you will get many errors.
Copy link to clipboard
Copied
Why does you use this long field names?
Copy link to clipboard
Copied
it is a requirements from a document
Copy link to clipboard
Copied
You mean that a document tells you these must be the form field names? Or that the document specifies what the user sees on screen (which is usually unrelated)?
Copy link to clipboard
Copied
yep tells me to use the ff names, on the thread above ive attached the pdf file.
Copy link to clipboard
Copied
Your issue likely comes from how this.getField(inputField) is being called. Ensure that the field names in your form exactly match the values in proposedInsured. Also, check if this.getField() is correctly referencing the form object. If you're working in an Adobe Acrobat JavaScript environment, this.getField() requires exact field names. Debug by printing inputField to confirm the values. A structured EHR system, like CareLogic, helps avoid such errors by standardizing data entry, ensuring a seamless carelogic login experience for users.