Copy link to clipboard
Copied
I want to delete pages if value is 0, but it delet another pages and only one page, there is somthing that I don't understand
var fx5 = this.getField("avgCbitq5");
var fx6 = this.getField("avgCbitq6");
var fx7 = this.getField("avgCbitq7");
if (fx5.value == "0"){
this.deletePages(12);
}
else if (fx6.value == "0"){
this.deletePages(13);
}
else if (fx7.value == "0"){
this.deletePages(14);
}
Copy link to clipboard
Copied
You can do it like this:
if (this.getField("fieldA").valueAsString=="0") this.deletePages(this.getField("fieldA").page);
if (this.getField("fieldB").valueAsString=="0") this.deletePages(this.getField("fieldB").page);
etc.
That way you're not using the actual page numbers, but the ones the fields are on, so you don't need to do it in reverse or hard-code the numbers into your code.
Copy link to clipboard
Copied
What pages want you delete?
Copy link to clipboard
Copied
I want to delet page 13, 14 and 15
Copy link to clipboard
Copied
OK
Copy link to clipboard
Copied
Hmm, I'd expect this to delete one of pages 13 or 14 or 15
or two of 13,16 or 14,16 or 13,15
or all three of 13,15,17
I didn't carefully check. Is that really what you want?
Copy link to clipboard
Copied
I want to delet page 13, 14 and 15. I added this code in AutoMailMerge to excute this script.
Copy link to clipboard
Copied
What's your question, then? Your code does that. Does it not work correctly? If so, what happens when you use it?
Also, where did you place it?
Copy link to clipboard
Copied
I want to delet page 13, 14 and 15. I added this code in AutoMailMerge to excute this script at the end. But it delets only one page page#(14). I know that pages start's at #Zero in the code.
What I want is to delete pages if a certian value is 0 but it didn't work at all as I want.
In this scenario it should delete 3 pages but it didn't work.
Copy link to clipboard
Copied
The document doesn't have any form field. Where does you use your script? Why does you use a if-else structure?
Copy link to clipboard
Copied
If you want to delete all three pages then you should do it either in a single command, or in reverse order, because when you delete page 13 what was before page 14 is now page 13, not 14, and the same for all other pages that follow it.
Copy link to clipboard
Copied
I lattely tried to do it but it's not working at all
Copy link to clipboard
Copied
You need to provide more information if you want help...
Copy link to clipboard
Copied
Okay : ) simply I need a script to check filed value, if this value == 0 then delete this page. I want to repeat it to all pages.
For example: page#1 contains fieldA if it's value equals to 0 then delete it, then in page#2 if fieldB value equals to 1 then don't delete it. I have 18 pages each page contains different fields.
Copy link to clipboard
Copied
You can do it like this:
if (this.getField("fieldA").valueAsString=="0") this.deletePages(this.getField("fieldA").page);
if (this.getField("fieldB").valueAsString=="0") this.deletePages(this.getField("fieldB").page);
etc.
That way you're not using the actual page numbers, but the ones the fields are on, so you don't need to do it in reverse or hard-code the numbers into your code.
Copy link to clipboard
Copied
WOOOOW! You saved my life. Thanks very much for your time.

