• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

1.5K

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

Community Expert , Aug 13, 2021 Aug 13, 2021

Try this:

this.deletePages(this.pageNum);

Votes

Translate

Translate
Community Expert ,
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.

Votes

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

Votes

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
Community Expert ,
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.

Votes

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.

Votes

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
Community Expert ,
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.

Votes

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
Community Expert ,
Aug 14, 2021 Aug 14, 2021

Copy link to clipboard

Copied

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

Votes

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?

Votes

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
Community Expert ,
Aug 14, 2021 Aug 14, 2021

Copy link to clipboard

Copied

LATEST

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

Votes

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
Community Expert ,
Aug 13, 2021 Aug 13, 2021

Copy link to clipboard

Copied

Try this:

this.deletePages(this.pageNum);

Votes

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
Community Expert ,
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).

Votes

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!

Votes

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.

Votes

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
Community Expert ,
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).

Votes

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
Community Expert ,
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.

Votes

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