Code to populate text fields just populating them with null.

New Here ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

Hey there ive got a code to conditionally populate text fields with the values of other text fields and i can get the info i  want in console but cant get it into the text fields for some reason the closest ive gotten so far is null printed where i want the data can anyone help me out?

 

var pageDictionary  = [
    "Ca",
    "Pu",
    "Sc",
    "St",
    "Ts",
    "Wh",
];
var fieldDictionary = [
    "Pn",
    "Dsc",
    "We",
    "Up",
    "Vol",
    "Tot",
];
var lineDictionary = {
    "Ca": 6,
    "Pu": 6,
    "Sc": 6,
    "St": 6,
    "Ts": 6,
    "Wh": 6,
}

var linesInFinalQuote = 0;
var i = 0; //Primary Itteration
var it = 0; //Secondary Itteration


for( i = 0; i < pageDictionary.length; i++)
{
    // Itteration through pages
    for(it = 0; it < lineDictionary[pageDictionary[i]]; it++)
    {
            // Itteration through each line on the page
            var itemVolume = String(this.getField(pageDictionary[i] + "Vol" + it).valueAsString);
           
            // Goes through each line as gets the volume of the line
            if(itemVolume > 0)
                    // Add to final page
                    linesInFinalQuote += 1;
                    // For loop to add this line to final page
                    for(var j = 0; j < fieldDictionary.length; j++)
                    {
                            (this.getField("Qu"+String(fieldDictionary[j])+String(linesInFinalQuote)).value = this.getField((pageDictionary[i] + fieldDictionary[j] + String(it)).value));
                    }
    }
}
/* page + field + linenumber
pagefieldlinenumber
page + string(field) + string(linenumber);
*/adobehelp1.pngadobehelp3.pngadopehelp2.png
TOPICS
JavaScript , PDF forms

Views

24

Likes

Translate

Translate

Report

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
Adobe Community Professional ,
Jul 18, 2022 Jul 18, 2022

Copy link to clipboard

Copied

LATEST

My guess is you're trying to access incorrect field names. I would recommend you add some debugging code, starting with printing out the names of the fields you're constructing, and making sure that using getField on those names returns a Field object, and not null.

Likes

Translate

Translate

Report

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