Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Auto Populated Fields do not Update/Populate after making a correction to field

New Here ,
Aug 31, 2016 Aug 31, 2016

Example:

We have a employee name field throughout the document:

     Employee Name_1 on page 1

     Employee Name_2 on page 2

     Employee Name_3 on page 8

     Employee Name_4 on page 10

So the script is on the first Employee Name_1, and it works fine. Type your name and the three other fields populate like magic.

Save the PDF, go get a coke or potty break.

Open the saved PDF and you see a typo on the Employee Name_1 field, so you correct. Ah, now it doesn't auto populate the rest of the employee_name fields:

Here is my script:

//set the vars

        var one = this.getField("Employees Name_1");

        var two = this.getField("Employees Name_2");

        var three = this.getField("Employees Name_3");

        var four = this.getField("Employees Name_4");

        //this function that checks if the destination field is blank and if so popluates it.

        function checkAndPopulate(orig,populate){

        if(populate.value==''||populate.value==null){populate.value=orig.value}

        }

        //copy value of one to two, three and four

        checkAndPopulate(one,two);

        checkAndPopulate(one,three);

        checkAndPopulate(one,four);

Not sure where my error my be?

Any help?

thanks,

jr7138

TOPICS
Acrobat SDK and JavaScript , Windows
670
Translate
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

correct answers 1 Correct answer

LEGEND , Aug 31, 2016 Aug 31, 2016

I'd recommend not using the On Blur event and instead place the script in the validate event of the Name_1 field. If you want it  to update the values of the other fields when it is updated, regardless of whether they are blank or not, the script can be simplified to the following:

// Custom Validate script for Name_1 field

getField("Name_2").value = event.value;

getField("Name_3").value = event.value;

getField("Name_4").value = event.value;

Translate
LEGEND ,
Aug 31, 2016 Aug 31, 2016

Where did you place that code? If in a field event, what is the field name and what is the event?

Translate
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
LEGEND ,
Aug 31, 2016 Aug 31, 2016

The checkAndPopulate function is set up to update the specified field only if it's currently blank (sort of). If that's not what you want, you'll have to change it.

Translate
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
New Here ,
Aug 31, 2016 Aug 31, 2016

George_Johnson:

Thanks for your question. I placed it here:

field.jpg

with an "On Blur" and runs as JavaScript.

jr7138

Translate
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
LEGEND ,
Aug 31, 2016 Aug 31, 2016

I'd recommend not using the On Blur event and instead place the script in the validate event of the Name_1 field. If you want it  to update the values of the other fields when it is updated, regardless of whether they are blank or not, the script can be simplified to the following:

// Custom Validate script for Name_1 field

getField("Name_2").value = event.value;

getField("Name_3").value = event.value;

getField("Name_4").value = event.value;

Translate
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
New Here ,
Aug 31, 2016 Aug 31, 2016
LATEST

George_Johnson:

Thanks for your great help. Your recommendation was spot on. Worked like a charm.

Best regards,

jr7138

Translate
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