Copy link to clipboard
Copied
In the past, to allow end users to delete a spawned template page that they no longer need, I have included a button on the template page that has the following JavaScript as a mouse up action:
this.deletePages(event.target.page);
This did exactly what it needed to do--remove the spawned page from the document (without removing the hidded template) regardless of what page the spawned template was on.
For some reason, when I use the same button with the same script in my current document, I get the following error when I try and use the button on the spawned template page:
RangeError: Invalid argument value.
Doc.deletePages:1:Field Delete Page A:Mouse Up
Is there some reason that this is not working? The only difference I can find is that in the current document, the template page is spawned from a drop down and the fields are not renamed, whereas in the document in which the delete page button works, the template is spawned from a check box and the fields were renamed.
Spawning JavaScript for the current document (w/the delete page issue):
if(event.willCommit)
{
switch(event.value)
{
case "Trust Termination":
this.getTemplate("TT Bene").spawn({bRename: false, bOverlay: false});
break;
}
}
Spawning JavaScript for the document in which the delete page button works:
if (event.target.value != "Off") {
this.getTemplate("BorrowerAdd").spawn(this.numPages, true, false) ;
}
There are no issues spawning the template page, only with using the delete button on the spawned page. Any insight on what is causing this error would be greatly appreciated!
Try this:
this.deletePages(this.pageNum);
Copy link to clipboard
Copied
There's no delete command in the codes you shared. Please post the code you're using to delete the page.
Also, it would be helpful if you could share the actual file with us.
Copy link to clipboard
Copied
The code used in the button to delete the spawned page is:
this.deletePages(event.target.page);
Copy link to clipboard
Copied
When you don't change the field names
event.target.page
gives you an array with pages of all buttons with the same name.
Copy link to clipboard
Copied
Thanks for the explanation. I have no other buttons with the same name in the document--the template page that is spawned has all unique field names.
Copy link to clipboard
Copied
When you spawn copies of the Template with the bRename parameter set as false you're creating additional copies of the fields on that page.
Copy link to clipboard
Copied
The button has the same name as the button on the template page.
Copy link to clipboard
Copied
Is there a way to just rename the one field?
Copy link to clipboard
Copied
No, it's either all, or none at all.
Copy link to clipboard
Copied
Try this:
this.deletePages(this.pageNum);
Copy link to clipboard
Copied
This is a bit dangerous. It's possible to be on one page and click a button that's on another, if you view the document in Continuous View ("Enable Scrolling") and the button appears at the top of the next page (or the bottom of the previous page).
Copy link to clipboard
Copied
That worked. Thank you so much!
Copy link to clipboard
Copied
That worked! Thank you so much Nesa.
Copy link to clipboard
Copied
"I get the following error when I try and use the button on the spawned template page:
RangeError: Invalid argument value."
This error most often means that you are using Acrobat Reader and trying to delete a "normal" page (vs spawned page).
Copy link to clipboard
Copied
Actually, I believe it's because of what Bernd pointed out, that the value of the page property is an array, not a number.