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

Template confusion

Community Beginner ,
Apr 12, 2021 Apr 12, 2021

Copy link to clipboard

Copied

I'm working on a form that has several templates which are spawned via buttons when required. I also am adding a button to reset the form and delete the spawned pages (so pages 12 to the end). The templates will be hidden, but I have them unhidden for now so that I can edit them. But when I test my reset button, it deletes the entire template. I assume this is because when it is unhidden, it IS page 12 and when it is hidden it is page -1 and the spawned page becomes page 12.

 

So do I just need to keep hiding and unhiding my template to test it or is there a more efficient method for editing when templates are involved?

TOPICS
General troubleshooting , How to , JavaScript , PDF forms

Views

587

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 2 Correct answers

Community Expert , Apr 12, 2021 Apr 12, 2021

You'll need to add a condition to your code that checks whether the template page is hidden before deleting those pages. If not, it means it's the actual Template page itself and you shouldn't delete it. You can set the code to hide it, instead.

Votes

Translate

Translate
Community Expert , Apr 12, 2021 Apr 12, 2021

If the template is page 12 when un-hidden, and the delete script deletes pages 12 to the end, then yes, it follows that the template page would be deleted.  I would suggest creating a button to toggle the visibility of your templates to make testing easier. This button can then be deleted or hidden for the final form. 

Votes

Translate

Translate
Community Expert ,
Apr 12, 2021 Apr 12, 2021

Copy link to clipboard

Copied

You'll need to add a condition to your code that checks whether the template page is hidden before deleting those pages. If not, it means it's the actual Template page itself and you shouldn't delete it. You can set the code to hide it, instead.

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 Beginner ,
Apr 12, 2021 Apr 12, 2021

Copy link to clipboard

Copied

Probably the best solution for the end product. 

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 ,
Apr 12, 2021 Apr 12, 2021

Copy link to clipboard

Copied

If the template is page 12 when un-hidden, and the delete script deletes pages 12 to the end, then yes, it follows that the template page would be deleted.  I would suggest creating a button to toggle the visibility of your templates to make testing easier. This button can then be deleted or hidden for the final form. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 Beginner ,
Apr 12, 2021 Apr 12, 2021

Copy link to clipboard

Copied

That seems like a logical workaround. Just wasn't sure if there was something I was missing about working with templates.

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 ,
Apr 12, 2021 Apr 12, 2021

Copy link to clipboard

Copied

LATEST

You are not missing anything.  Templates are only ever visible for development. During normal use they should always be hidden. 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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