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

Duplicate Form Not Refreshing Fields But Third Form Is. How Do I Get The Second Form to Clear Data

New Here ,
Aug 05, 2020 Aug 05, 2020

Copy link to clipboard

Copied

Hello, I'm new here and new to Acrobat. I have successfully added a button to a form I want to duplicate and it is duplicating the form correctly. This issue I'm having is that I've added a batch Rename in the javascript but it's only taking effect on the third page generated. The page that's generated after the first button press is a direct copy of the original(fields and all), but the button on the newly generated form produces a clean form with empty fields. How do I get my original form button to produce a clean form with empty fields on the first duplication of the form?

TOPICS
Acrobat SDK and JavaScript

Views

1.1K

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

correct answers 1 Correct answer

Community Expert , Aug 05, 2020 Aug 05, 2020

You can hide the template page and then spawn copies from it as needed. The fields on the hidden page will remain empty, and therefore so will be the new ones you create.

 

The programmatic approach to resetting just the new fields would be to look at the their page property, since you know what's the page number of the spawned page, so you can reset only those fields.

Votes

Translate

Translate
Community Expert ,
Aug 05, 2020 Aug 05, 2020

Copy link to clipboard

Copied

What script does you use at the button?

Votes

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
New Here ,
Aug 05, 2020 Aug 05, 2020

Copy link to clipboard

Copied

var pageCount = 0;

var pagePos = 0;

pageCount = this.numPages;

pagePos = pageCount-2;

var b = getTemplate("Add Benefit");

b.spawn({nPage: pagePos, bRename: true, bOverlay: false});

Votes

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
New Here ,
Aug 05, 2020 Aug 05, 2020

Copy link to clipboard

Copied

The fields are getting renamed but it's still duplicating the data from the original form. If I leave the original form blank, and generate a second one with the button, the third one has all the fields cleared. I'm not sure what I'm missing here. Any help would be appreciated!

 

Votes

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
Community Expert ,
Aug 05, 2020 Aug 05, 2020

Copy link to clipboard

Copied

You're not missing anything. When you spawn a copy of a Template page it retains all the values in all of the fields on it, even if you selected to automatically rename them. You can reset them yourself later on in your code, since you can figure out their names, or even just their page number.

Votes

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
New Here ,
Aug 05, 2020 Aug 05, 2020

Copy link to clipboard

Copied

I appreciate it. What I would really like to do is retain the info on the original form and spawn a new and clean form duplicate so the client can stack as many benefit pages as necessary. Is there another way to achieve this? I've attempted a reset form function after the new form is spawned but it clears the original form as well. Any ideas? What would be the programmatic approach? Thank you again.

Votes

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
Community Expert ,
Aug 05, 2020 Aug 05, 2020

Copy link to clipboard

Copied

You can hide the template page and then spawn copies from it as needed. The fields on the hidden page will remain empty, and therefore so will be the new ones you create.

 

The programmatic approach to resetting just the new fields would be to look at the their page property, since you know what's the page number of the spawned page, so you can reset only those fields.

Votes

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
New Here ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

I've been trying to get the hidden template function to work but I must be missing something. If I set the document as hidden, then go to preview, it doesn't operate any differently and when I go back to Organize Pages, the box is checked because it's not hidden. I then dragged and dropped a new thumbnail copy of the original document and set the first copy to hidden. It disappears from view and I still have the original document but in testing, the behavior is the same. I then duplicated the page with all new field names and set the original page with the default names as the hidden template, and now all fields match the original blank document I set to hidden(all forms that were filled out are now blank). I feel like there must be something in my javascript that is not working with the acrobat settings and there is some type of conflict. I am new to this and feel like I cultivated a more complicated situation. Any help is very welcome. Thank you. I'm new

Votes

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
Community Expert ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

Can you share the form?

Votes

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
New Here ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

Unfortunately, it contains client information and I cannot share that in a public forum. Sorry

Votes

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
New Here ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

Do I need to rename the hidden template and then reference that with the getTemplate method so my original document name doesn't overwrite it?

Votes

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
Community Expert ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

No, you don't need to do that. You said you set the document as hidden... Why did you do that?

Votes

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
New Here ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

I'm not sure, but in the Organize Pages tool, when I uncheck the box with the form name in the page template modal, it hides the thumbnail if there is another page present so I cntrl + drag a new copy of the thumbnail and hide the original assuming that it was storing that as a template to reference in the getTemplate( ) method I call in the javascript when the button is pressed to give me a direct copy of the template, but now it's back to duplicating the field info from each prior page. Maybe some of my confusion is linked to the fact that it is a one page pdf and I was thinking there was a naming conflict as it seems that the Add Benefit name exists for the original file and the file being modified, so I wasn't sure if that was coming into play as a conflict

Votes

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
Community Expert ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

You can't hide a Template page if it's the only page in the file... There must be at least one visible page at all times.

Votes

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
Community Expert ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

Open the document with the one page. Add a empty page. Hide the template page. Spawn the template page in the Javascript console. Delete the empty page. Save the document.

Votes

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
New Here ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

In the Organize Pages tool, I click More and select Page Templates. In the Name field, I input the name of my template and to make it hidden, I uncheck the box but it hides the thumbnail as well. I thought that it was still supposed to show in that view but not on the document. I just started using acrobat yesterday so I am pretty new to all this

Votes

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
New Here ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

I like your idea. How do I access the Javascript console? If I can access it, how do I spawn it without a button or a command sequence to initiate it?

Votes

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
Community Expert ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

Open the console:

ctrl-j or cmd-j

There execute:

var b = getTemplate("Add Benefit");

b.spawn({bRename: true, bOverlay: false});

 

 

Votes

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
New Here ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

So, that absolutely works for generating a new form on the first click. However, any selections on the first page are also cleared and whatever you select on the duplicated form selects it also on the original form. I can see we're going in the right direction and I really appreciate your time. Do you have anymore suggestions or tweaks I could implement that will leave the info alone on the original and keep the new functionality of a fresh new page right off the original? Thank you

Votes

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
New Here ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

I feel like when I'm adjusting options in Page Template, Page Settings, etc Acrobat is inserting boiler plate code along with my javascript and I'm wondering if there is a sequence of changes I need to make so there isn't any conflict between the two. 

Votes

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
New Here ,
Aug 06, 2020 Aug 06, 2020

Copy link to clipboard

Copied

LATEST

I found a solution to the issue. What I did was create a thumbnail copy of the page and set the field names to something obscure that acrobat wouldn't try to duplicate or use. I hid the duplicate copy of the page and am using that empty form as the spawn. I really appreciate both of you helping me with this! Have a great day

Votes

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