Skip to main content
meximeltmariposa
Participant
March 2, 2018
Answered

Limit number of times a button spawns a document -Javacript

  • March 2, 2018
  • 2 replies
  • 452 views

I am working on an inventory list that is 2 pages. The second page I want to be optional so I decided to use JavaScript (for spawning). I applied this script to my button and it does work. My issue is I only want it to spawn the document once. At this time the button spawns the same document multiple times.

var expTplt = getTemplate("P0Inventorylist");

expTplt.spawn(numPages,false,false);

I only want the user to be able to pull this one time if additional lines are needed. What is the coding I would add to the one above that will limit the user to only pulling this one time?

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer try67

Add this to the end of the code:

event.target.display = display.hidden;
If the button is on the page that is getting spawned then add a command to hide the spawned copy, as well, like this:

this.getField("Name of spawned button").display = display.hidden;

2 replies

meximeltmariposa
Participant
March 2, 2018

Thanks for this. It worked like a charm!

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
March 2, 2018

Add this to the end of the code:

event.target.display = display.hidden;
If the button is on the page that is getting spawned then add a command to hide the spawned copy, as well, like this:

this.getField("Name of spawned button").display = display.hidden;