Expand my Community achievements bar.

Autopopulate not working (I tried)

Avatar

Level 4

So far this is what I have:

number file

*initialize

fileNoScript.populatefileNo(

this);

*change

fileNoScript.getDesc(xfa.event.newText

, titledescrip, disposition);

I created a variable - fileNoScript

File NumberTitleDisposition
dropdown labled number filetext field labled titledescriptext field labled dispositon

See Variable

form1.#variables[0].fileNoScript - (JavaScript, client)

form1.purchaseOrder.#variables[0].fileNoScript

- (JavaScript, client)

// This script object controls the interaction between the file number, title and disposition fields.

// When you fill the fileNo, filetitle and filedisposition arrays, make sure they have the same number of array indices in

// each array i.e. for every part number, there should be a matching description and price.

// Array of part numbers.

var

fileNo = new Array(" ",

                              "102-01"

,

                              "102-02"

,

                              "102-03"

,

                              "102-04"

,

                              "102-05"

,

                              "102-06"

,

                              "102-07"

,

                              "102-08"

,

                              "102-09"

,

                              "102-10"

,

                              "102-11");

// Array of title descriptions.

var

filetitle = new Array(null,

                         "Correspondence travel, message, historical, Audiovisual Collection Database, Advisory Board Subject Files"

,

                         "Visitor File"

,

                         "Director's Travel Files"

,

                         "General Subject Files"

,

                         "Director's Message File"

,

                         "Central Subject File"

,

                         "Historical File"

,

                         "Directorate Correspondence Tracking System"

,

                         "Audiovisual Collection Database"

,

                         "Director's Audiovisual Collection"

,

                         "Advisory Board Subject Files");

// Array of part prices.

var

fieldisposition = new Array(null,

                         "Permanent. Close at the end of the fiscal year. Transfer to the WNRC 5 years after closing. Transfer to the NARA when 20 years old."

,

                         "Temporary. Retain in Directors Staff office for 5 years. Destroy when no longer needed for operations."

,

                         "Permanent. Cut off at the end of the fiscal year. Transfer inactive files to the WNRC 5 years after closing. Transfer to the NARA when 20 years old."

,

                         "Permanent. Cut off every two years at the end of the fiscal year. Transfer inactive files to the WNRC 5 years when no longer needed for operations. Transfer to the NARA when 20 years old.",

                         "Permanent. Cut off every 3 years at the end of the fiscal year. Transfer inactive files when no longer needed for operations to the WNRC. Transfer to the NARA when 20 years old."

,

                         "Permanent. Cut off files at the end of the fiscal year. Transfer inactive files to the WNRC every 5 years when no longer needed for operations. Transfer to the NARA when 20 years old.",

                         "Permanent. Cut off files every 2 years at the end of the fiscal year. Transfer inactive files every 5 years to the WNRC when no longer needed for operations. Transfer to the NARA when 20 years old.",

                         "Permanent. Cut off at the end of the fiscal year. Transfer inactive files to the WNRC every 5 years. Transfer to the NARA when 20 years old.",

                         "Permanent. Cut off at the end of the fiscal year. Transfer files to the WNRC every 5 years when no longer needed for operations. Transfer to the NARA when 20 years old.",

                         "Permanent. Cut media files off at the end of the fiscal year. Transfer media to the WNRC every 5 years when no longer needed for operations. Transfer to the NARA when 20 years old.",

                         "Permanent. Cut files off at the end of the fiscal year. Transfer inactive files to the WNRC every 5 years when no longer needed for operations. Transfer to the NARA when 20 years old.");

// Populate the file number Drop-down List.

function

populatefileNo(dropdownField)

{

               var i;

               for (i=0; i < fileNo.length; i++)

                         dropdownField.addItem(fileNo[i]);

}

// Populate the title and disposition fields.

function

getDesc(fileNumber, titleField, itemdisposition)

{

var i;

for (i = 0; i < fileNo.length; i++) // Go through the entire list of file numbers to find the one that is currently selected.

    {

     if (fileNo[i] == fileNumber) // When we find the file number currently selected.

     {

     titleField.rawValue

= fileDesc[i]; // Put the description in the title field

     dispositonField.rawValue

= filedisposition[i]; // and put the disposition in the disposition field.

     break;                                      // No need to go further if there is a match.

      }

     }

}

Of course, it doesn't work!!!!

Help Please!

16 Replies

Avatar

Level 10

The mistake you did was referencing the wrong array variable in your function.

Try replacing your function with the below code and it should work..

// Populate the title and disposition fields.


function getDesc(fileNumber, titleField, itemdisposition){
var i;

     for (i = 0; i < fileNo.length; i++) // Go through the entire list of file numbers to find the one that is currently selected.
     {
          if (fileNo[i] == fileNumber) // When we find the file number currently selected.
          {
                titleField.rawValue = filetitle[i]; // Put the description in the title field
                itemdisposition.rawValue = fieldisposition[i]; // and put the disposition in the disposition field.
                break;                                      // No need to go further if there is a match.
          }
     }

}

Thanks

Srini

Avatar

Level 4

Thanks....but,

It is still not working. Nothing is happening. Also, when I click the dropdown list it only displays 2 values when I have a whole list of values.

(Also, I don't know if I am being clear but, I would like to select a file number from the dropdown and the title and disposition autopopulate.)

What else can I do??????

Avatar

Level 10

Check the file I did.. I used the same code you have posted earlier (except the modifed function with the correct array variable name).

I saved the file as Dynamic XML File (File Menu -> Save As) and in the Form Properties I set the Render PDF As dynamic XML form.

https://acrobat.com/#d=1mxIvs4LqeATqfkcP1bS1Q

Thanks

Srini

Avatar

Level 4

Thanks so much Srini!

I still haven't figured out why my form is behaving badly.

Avatar

Level 10

May be you can post your form here, so I can have a look at it.

Thanks

Srini

Avatar

Level 4

Now I am trying to get the delete a row button to work -- there is always something!

Avatar

Level 4

Siri,  I am not sure if it posted - how do I post?

Avatar

Level 10

Steps to upload the document

1) goto acrobat.com website
2) login with your Adobe login/password.
3) In Actions you will find Upload. Select your form and upload.
4) After uploading, select form name in All Files section and right click and select share.
5) Check the checkbox "Allow anyone with a link to view this document".
6) Copy the URL link and post it in the forum.

Thanks

Srini

Avatar

Level 4

Thanks both files are there - Suri22 and OfficePlan_variables

I decided to use Suri22. I have added a add row button and remove row button and I cannot get them to work.

Avatar

Level 10

Can you post the links to the files in the forum..

Thanks

Srini

Avatar

Level 10

There are two issues in the document.

1) Inside the script object the following line is repeating twice. (which I commented out in the attached file)    

          form1.purchaseOrder.#variables[0].fileNoScript - (JavaScript, client)

2) You declared the variable in the Script object as "fieldisposition" but in the getDesc function you are referencing to the variable as "filedisposition". I corrected the spelling mistake in the variable declaration.

The corrected file is uploaded at the below location.

https://acrobat.com/#d=LpDcOFxzRgI4cnIpAK58yg

Thanks

Srini

Avatar

Level 4

Thanks!

Can you take a look at the second file and let me know why the add row buttons and delete row buttons are not working?

Thank you soo much for your prompt response!

Avatar

Level 10

You did not set the "Item" row "Repeat Row for Each Data Item" to be checked.

If you want to repeat Subform/ Table/ Row at runtime using instanceManager, you need to check this check box.

RepeatSubform.jpg

Thanks

Srini

Avatar

Level 4

Srini,

Words cannot express......

Thank you so much!

Have a good day!

Avatar

Level 1

Hello guys,

Is there a limit to the amount of variables that can be put in the array?

I am using the Purchase order from Livecycle and I have not modified anything, the only thing that makes it not to work is the length of the arrays.

the code I am using is ( it works perfectly untill I add more items to the array, I need to add 2794 elemnets. maybe there is another way to achieve what I am trying to do?):

form1.Main.#variables[0].partNoScript - (JavaScript, client)

  // This script object controls the interaction between the part number, description and unit price fields.

  // When you fill the partNo, partDesc and partPrice arrays, make sure they have the same number of array indices in

// each array i.e. for every part number, there should be a matching description and price.

// Array of part numbers.

var partNo = new Array(" ",

                                                     "27001",

"27002",

"27003",

"27004",

// Array of part descriptions.

var partDesc = new Array(null,

                                                            "4M. SHORING BEAM",

"3M. SHORING BEAM",

"2M. SHORING BEAM",

"4,00M. SUPPORT GIRDER");

// Array of part prices.

var partPrice = new Array(null,

                                                              113.44,

87.41,

64.53,

122.91);

// Populate the part number Drop-down List.

function populatePartNo(dropdownField)

{

      var i;

      for (i=0; i < partNo.length; i++)

         dropdownField.addItem(partNo[i]);

}

// Populate the description and unit price fields.

function getDesc(partNumber, descField, itemPrice)

{

   var i;

   for (i = 0; i < partNo.length; i++)                    // Go through the entire list of part numbers to find the one that is currently selected.

   {

      if (partNo[i] == partNumber)                              // When we find the part number currently selected.

            {

        descField.rawValue = partDesc[i];          // Put the description in the description field

              itemPrice.rawValue = partPrice[i];          // and put the unit price in the unit price field.

              break;                                                                                // No need to go further if there is a match.

            }

   }

}

Thanks in advance