Skip to main content
Psiomicron
Participant
April 30, 2026
Question

After deleting a spawned template with multiple pages, searching for a fieldname shows it on a page number that it existed on before.

  • April 30, 2026
  • 2 replies
  • 20 views

I have a form with checkboxes that will create templates in the form to fill out. I would like to uncheck the box and have it delete that particular form. I do this now by searching for a certain fieldname on that page. If it finds it, delete the page. This is my issue:

Say I have form 1 (page1), 2 (page2), 3 (page3) created. I remove 2. It removes and now there is form 1 (page1), and form 3 (now page2). When I try to delete form 3 now it searches for the specific fieldname, but it tells me that the field name is still on page 3, and thus can’t delete a page that is nonexistent, leaving form 3 (page2) still there. 

How do I get it to refresh (I have used “this.calculateNow();” before AND after deletion but dosen’t work) so it sees the fieldname on the proper page, ie page 2.

Here is my code:

if (trackerField != null) {

        this.calculateNow();
        var trackerField = this.getField("PageTracker2_" + cbName);
        var pageToDelete = Number(trackerField.value);
        
        // Remove the tracker field
        this.removeField("PageTracker2_" + cbName);

       //Let me know what page the tracker is on
        app.alert("On page " + pageToDelete, 3)
        // Delete the page
        this.deletePages(pageToDelete);
        this.calculateNow();

        }
 

Thanks!

 

    2 replies

    TᴀW
    Legend
    May 1, 2026

    If worst comes to the worst, you could keep track internally of which form is on which (real) page.

    id-extras.com | InDesign tools & scripts for typesetters, form designers, and translators
    Bernd Alheit
    Community Expert
    Community Expert
    May 1, 2026

    How does you change the value of the trackerField?