Skip to main content
Known Participant
November 24, 2022
Answered

this.getField returns null

  • November 24, 2022
  • 3 replies
  • 8955 views

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..

Correct answer ravin_2043
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.

3 replies

ravin_2043Correct answer
New Participant
February 5, 2025
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.
S_S
Community Manager
Community Manager
March 11, 2025

Hi @ravin_2043,

 

Hope you are doing well. 

 

Thanks for sharing the detailed information on the topic. 

Marking this as a correct answer so future users can have this conversation stay atop for similar references.


Regards,
Souvik.

Bernd Alheit
Community Expert
November 24, 2022

Why does you use this long field names?

Known Participant
November 24, 2022

it  is a requirements from a document

 

Brainiac
November 24, 2022

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)?

Nesa Nurani
Community Expert
November 24, 2022

It means there is no such field.

What exactly are you trying to achieve ?

Known Participant
November 24, 2022

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

Known Participant
November 24, 2022

sorry, not text field but radio button. see attached photo