Skip to main content
Known Participant
August 30, 2021
Question

Spawning one template page multiple times

  • August 30, 2021
  • 2 replies
  • 983 views

I have form that requires a template page to spawn multiple times, based on the number of additional "recipients" that are added to the form. The spawned page asks for information that answers need to be unique to each additional "recipient". The total number of "recipients" will most likely range from 1 to 10 (but could be highter). This template page ("Disb Rec Add") is spawned from another spawned template that only appears once and does not have the fields renamed. 

 

 

 

The script to spawn "Disb Rec Add" is:

 

this.getTemplate("Disb Rec Add").spawn(this.numPages, true, false) ;

 

 

 

The above code has the page spawn to the end of the document, with the fields renamed and not overlay.

 

On the spawned template there is a check box with the same code to spawn another page if needed (currently each page is spawned from the previous spawned page as needed).

 

 

 

The template page ("Disb Rec Add") includes some fields with calculation scripts and a drop down field with a complex validation script (The script hides/shows/clears various fields based on the drop down selection). Since the template page spawns with renamed fields, I added the following to the scripts that refer to fields on the spawned page:

 

var cPreFix = "";

var aFieldName = event.target.name.split(".");

if(aFieldName.length > 2)

{

cPreFix = aFieldName[0] + "." + aFieldName[1] + ".";

}

 

 

 

As well as:

 

cPrefix +   

 

before each field name.

 

 

 

The above has worked in the past, but for some reason the drop down's validation script on the spawned pages is glitchy -- some things don't appear or hide as they should or only work when selected in a certain order. The script works perfectly on the template page, but gets glitchy only when it is spawned. Also, using the cPrefix fix to ignore the renamed field prefix also may be causing some of the drop down selections on one spawned page to effect another.

 

 

 

Is there any way to make this work properly? I tried to give all the pertinent information, but hope I didn't confuse things. If anyone needs more clarification, just let me know. Thanks in advance for your help!

This topic has been closed for replies.

2 replies

Participant
September 2, 2024

Can we get an update on this please

BarlaeDC
Community Expert
Community Expert
August 31, 2021

Hi,

 

Are you able to share the document, or a document that shows the issue, so that we can investigate further?

slaronAuthor
Known Participant
August 31, 2021

Thanks, but unfortunately, I cannot share the actual document and I don't have the time (right now) to recreate a dummy document to replicate the issues. 

 

In the meantime, I changed the drop down (with the validation script for the different selections) to check box selections (there only 6 selections total). For each check box, I added the mouse up action JavaScript for the hide/show fields that selection. It is not ideal, but it is working on the spawned pages without any issues. The one thing I cannot make work with the check boxes is how to reset fields if/when another selection is chosen. 

 

Thanks again.