Highlighted

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

New Here ,
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?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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.

TOPICS
Acrobat SDK and JavaScript, Comment review and collaborate PDF, Crash or freeze, Create PDFs, Edit and convert PDFs, General troubleshooting, How to, Install update and subscribe to Acrobat, PDF forms, Print and prepress, Rich media and 3D, Scan documents and OCR, Security digital signatures and esignatures, Standards and accessibility

Views

90

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

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

New Here ,
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?

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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.

TOPICS
Acrobat SDK and JavaScript, Comment review and collaborate PDF, Crash or freeze, Create PDFs, Edit and convert PDFs, General troubleshooting, How to, Install update and subscribe to Acrobat, PDF forms, Print and prepress, Rich media and 3D, Scan documents and OCR, Security digital signatures and esignatures, Standards and accessibility

Views

91

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
Aug 05, 2020 0
Adobe Community Professional ,
Aug 05, 2020

Copy link to clipboard

Copied

What script does you use at the button?

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
Reply
Loading...
Aug 05, 2020 0
New Here ,
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});

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
Reply
Loading...
Aug 05, 2020 0
New Here ,
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!

 

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
Reply
Loading...
Aug 05, 2020 0
Most Valuable Participant ,
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.

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
Reply
Loading...
Aug 05, 2020 0
New Here ,
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.

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
Reply
Loading...
Aug 05, 2020 0
Most Valuable Participant ,
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.

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
Reply
Loading...
Aug 05, 2020 0
New Here ,
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

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
Reply
Loading...
Aug 06, 2020 0
Adobe Community Professional ,
Aug 06, 2020

Copy link to clipboard

Copied

Can you share the form?

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
Reply
Loading...
Aug 06, 2020 0
New Here ,
Aug 06, 2020

Copy link to clipboard

Copied

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

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
Reply
Loading...
Aug 06, 2020 0
New Here ,
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?

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
Reply
Loading...
Aug 06, 2020 0
Most Valuable Participant ,
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?

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
Reply
Loading...
Aug 06, 2020 0
New Here ,
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

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
Reply
Loading...
Aug 06, 2020 0
Adobe Community Professional ,
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.

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
Reply
Loading...
Aug 06, 2020 0
Most Valuable Participant ,
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.

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
Reply
Loading...
Aug 06, 2020 0
New Here ,
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

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
Reply
Loading...
Aug 06, 2020 0
New Here ,
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?

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
Reply
Loading...
Aug 06, 2020 0
Adobe Community Professional ,
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});

 

 

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
Reply
Loading...
Aug 06, 2020 0
New Here ,
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

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
Reply
Loading...
Aug 06, 2020 0
New Here ,
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. 

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
Reply
Loading...
Aug 06, 2020 0
New Here ,
Aug 06, 2020

Copy link to clipboard

Copied

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

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
Reply
Loading...
Aug 06, 2020 0