Deleting Spawned Pages

New Here ,
Jan 23, 2021 Jan 23, 2021

Copy link to clipboard

Copied

Hi all

 

I am working on a form in Acrobat. It is a training form with Competent/Not Yet Competent (C/NYC). The form will auto select C/NYC depending on the checkbox selections. If they are Not Yet Competent then two pages will spawn for the reassessment component. These forms  are hidden at the start.

 

For Competent the script will delete the last two pages. As these pages are hidden at the start and iff the person is assessed as Competent at the start the calculate script runs but stops at the deletepages part of the script and won't proceed.

 

Is there a way for this delete script to take into account the pages may or may not be there. The script I'm using is as follows:

 

if (this.getField("Check Box1").value == "Yes"

    && this.getField("Check Box2").value == "Yes"

    && this.getField("Check Box3").value == "Yes"

    && this.getField("Check Box4").value == "Yes"

    && this.getField("Check Box5").value == "Yes"

    && this.getField("Check Box6").value == "Yes"

    && this.getField("Check Box7").value == "Yes" ) {

    this.getField("ResultCB").value = "Yes";

    this.deletePages({nStart: 5, nEnd: 6 });

    }

 

Any assistance is appreciated.

 

Gary

 

TOPICS
JavaScript, PDF forms

Views

99

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

Most Valuable Participant , Jan 25, 2021 Jan 25, 2021
Yes, add it before: this.deletePages({nStart: 5, nEnd: 6 }); Like this: if (this.numPages>=7) this.deletePages({nStart: 5, nEnd: 6 });

Likes

Translate

Translate
Most Valuable Participant ,
Jan 24, 2021 Jan 24, 2021

Copy link to clipboard

Copied

You can check the number of pages in the file before deleting them. If the number is less than 7, don't proceed.

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
New Here ,
Jan 24, 2021 Jan 24, 2021

Copy link to clipboard

Copied

try

 

How would I do that? I am not well versed in Javascript.

 

Gary

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
Most Valuable Participant ,
Jan 24, 2021 Jan 24, 2021

Copy link to clipboard

Copied

Add this to the if condition:

if (this.numPages>=7 && ...

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
New Here ,
Jan 24, 2021 Jan 24, 2021

Copy link to clipboard

Copied

try

 

Where would I place that in the script provided? If I place it at the start then line 8 of the script won't occur if >=7. Is that correct?

 

Gary

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
Most Valuable Participant ,
Jan 25, 2021 Jan 25, 2021

Copy link to clipboard

Copied

Yes, add it before:

this.deletePages({nStart: 5, nEnd: 6 });

Like this:

if (this.numPages>=7) this.deletePages({nStart: 5, nEnd: 6 });

 

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
New Here ,
Jan 25, 2021 Jan 25, 2021

Copy link to clipboard

Copied

LATEST

Worked a treat. Thank you.

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