Skip to main content
Divine_amazement5D95
Participant
Aug 15, 2019 2:01 PM UTC
Answered

Deleting spawned pages

I am trying to find a script that will delete all spawned pages, regardless of the number of pages.  I want to be able to set the document back to original.  The number of spawned pages may vary.

This topic is closed to new replies. Start a new post to keep the conversation going.
try67
try67Correct answer
Community Expert
Aug 15, 2019 5:05 PM UTC

This is my simplified solution to my problem, no matter how many pages were spawned there will always be a page 1 until there isn't so I have a reset button that resets all the fields and then deletes page 1 twelve times.  It will stop deleting when there is no longer a page 1 to delete.

n=app.alert("Are you sure you want to Reset?",2,1);

if (n==1){

this.resetForm();   

}

if (numPages > 1) {

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

deletePages(1);

}


That's very redundant. Instead, you can use this single command:

if (numPages > 1) {

     this.deletePages(1, this.numPages-1);

}

7 replies

Bernd Alheit
Community Expert
Community Expert
Aug 15, 2019 2:08 PM UTC

Does you use form fields on the spawned pages?

Translate
Divine_amazement5D95
Participant
Aug 15, 2019 2:11 PM UTC

I do use form fields on the pages which have all unique names, there are 9 templates that could be spawned but possible only a couple will be

Translate
Bernd Alheit
Community Expert
Community Expert
Aug 15, 2019 2:19 PM UTC

The field names of the spawned pages have the following form:

P<page no>:<template name>:<field name>

When you check all fields in the document you can find all spawned pages.

Translate