Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Button to delete a spawned template page not working

Explorer ,
Aug 13, 2021 Aug 13, 2021

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!

TOPICS
General troubleshooting, JavaScript, PDF forms

Views

149

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Aug 13, 2021 Aug 13, 2021
Try this: this.deletePages(this.pageNum);

Likes

Translate

Translate
Adobe Community Professional ,
Aug 13, 2021 Aug 13, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 13, 2021 Aug 13, 2021

Copy link to clipboard

Copied

The code used in the button to delete the spawned page is:

 

this.deletePages(event.target.page);

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 13, 2021 Aug 13, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 14, 2021 Aug 14, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 14, 2021 Aug 14, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 14, 2021 Aug 14, 2021

Copy link to clipboard

Copied

The button has the same name as the button on the template page.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 14, 2021 Aug 14, 2021

Copy link to clipboard

Copied

Is there a way to just rename the one field?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 14, 2021 Aug 14, 2021

Copy link to clipboard

Copied

LATEST

No, it's either all, or none at all.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 13, 2021 Aug 13, 2021

Copy link to clipboard

Copied

Try this:

this.deletePages(this.pageNum);

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 14, 2021 Aug 14, 2021

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).

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 14, 2021 Aug 14, 2021

Copy link to clipboard

Copied

That worked. Thank you so much!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 14, 2021 Aug 14, 2021

Copy link to clipboard

Copied

That worked! Thank you so much Nesa.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 14, 2021 Aug 14, 2021

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).

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 14, 2021 Aug 14, 2021

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines