View Single Post
  #3  
Old December 5th, 2016, 02:26 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Suppress specific pages on two values

First of all, you're doing exactly the same thing when the value of "PLANOPTION" is "500," "750," or "1000" so you could simplify your code by writing it like this:
Code:
switch (Field("PLANOPTION")) {
  case "200":
  FusionPro.Composition.SetBodyPageUsage("200 P1", true)
  FusionPro.Composition.SetBodyPageUsage("200 P2", true)
  FusionPro.Composition.SetBodyPageUsage("200NonInsured P1", true)
  FusionPro.Composition.SetBodyPageUsage("200NonInsured P2", true)
  break;

  case "250":
  FusionPro.Composition.SetBodyPageUsage("250 P1", true)
  FusionPro.Composition.SetBodyPageUsage("250 P2", true)
  FusionPro.Composition.SetBodyPageUsage("250_500_750_1000NonInsured P1", true)
  FusionPro.Composition.SetBodyPageUsage("250_500_750_1000NonInsured P2", true)
  break;

  case "500":
  case "750":
  case "1000":
  FusionPro.Composition.SetBodyPageUsage("500_750_1000 P1", true)
  FusionPro.Composition.SetBodyPageUsage("500_750_1000 P2", true)
  FusionPro.Composition.SetBodyPageUsage("250_500_750_1000NonInsured P1", true)
  FusionPro.Composition.SetBodyPageUsage("250_500_750_1000NonInsured P2", true)
  break;
}
Quote:
Originally Posted by ricky10ss View Post
But there is a value field called "Amount" that if there is no value for 250, 500, 750 and 1000 plans they do not get 250_500_750_1000NonInsured P1 or 250_500_750_1000NonInsured P2. What would you recommend doing for this?
In other words, you only want to enable the "250_500_750_1000NonInsured" pages if the "Amount" field contains a value? You can do that:
Code:
switch (Field("PLANOPTION")) {
  case "200":
  FusionPro.Composition.SetBodyPageUsage("200 P1", true)
  FusionPro.Composition.SetBodyPageUsage("200 P2", true)
  FusionPro.Composition.SetBodyPageUsage("200NonInsured P1", true)
  FusionPro.Composition.SetBodyPageUsage("200NonInsured P2", true)
  break;

  case "250":
  FusionPro.Composition.SetBodyPageUsage("250 P1", true)
  FusionPro.Composition.SetBodyPageUsage("250 P2", true)
  FusionPro.Composition.SetBodyPageUsage("250_500_750_1000NonInsured P1", Field("Amount"))
  FusionPro.Composition.SetBodyPageUsage("250_500_750_1000NonInsured P2", Field("Amount"))
  break;

  case "500":
  case "750":
  case "1000":
  FusionPro.Composition.SetBodyPageUsage("500_750_1000 P1", true)
  FusionPro.Composition.SetBodyPageUsage("500_750_1000 P2", true)
  FusionPro.Composition.SetBodyPageUsage("250_500_750_1000NonInsured P1", Field("Amount"))
  FusionPro.Composition.SetBodyPageUsage("250_500_750_1000NonInsured P2", Field("Amount"))
  break;
}
Or you could not use a switch statement at all:
Code:
var front = Field("PLANOPTION") > 250 ? '500_750_1000' : '';
var back = Field("PLANOPTION") > 200 ? '250_500_750_1000' : '';
for (var i=1; i<=2; i++) {
  FusionPro.Composition.SetBodyPageUsage((front || Field("PLANOPTION")) + ' P' + i, true);
  if (!back || Field("Amount"))
    FusionPro.Composition.SetBodyPageUsage((back || Field("PLANOPTION")) + 'NonInsured P' + i, true);
}
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote