MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   Getting Started, Learning, Etc. (http://forums.pti.com/forumdisplay.php?f=38)
-   -   Suppress specific pages on two values (http://forums.pti.com/showthread.php?t=4740)

ricky10ss December 5th, 2016 01:21 PM

Suppress specific pages on two values
 
Below is the onRecordStart rule I was using but I found out I need to adjust to another field. The switch rule below is turning on the specific pages based off their plan. 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?

switch (Field("PLANOPTION"))
{
case "200":
FusionPro.Composition.SetBodyPageUsage("200 P1", true)
FusionPro.Composition.SetBodyPageUsage("200 P2", true)
FusionPro.Composition.SetBodyPageUsage("200NonInsu red P1", true)
FusionPro.Composition.SetBodyPageUsage("200NonInsu red P2", true)
break;

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

case "500":
FusionPro.Composition.SetBodyPageUsage("500_750_10 00 P1", true)
FusionPro.Composition.SetBodyPageUsage("500_750_10 00 P2", true)
FusionPro.Composition.SetBodyPageUsage("250_500_75 0_1000NonInsured P1", true)
FusionPro.Composition.SetBodyPageUsage("250_500_75 0_1000NonInsured P2", true)
break;

case "750":
FusionPro.Composition.SetBodyPageUsage("500_750_10 00 P1", true)
FusionPro.Composition.SetBodyPageUsage("500_750_10 00 P2", true)
FusionPro.Composition.SetBodyPageUsage("250_500_75 0_1000NonInsured P1", true)
FusionPro.Composition.SetBodyPageUsage("250_500_75 0_1000NonInsured P2", true)
break;

case "1000":
FusionPro.Composition.SetBodyPageUsage("500_750_10 00 P1", true)
FusionPro.Composition.SetBodyPageUsage("500_750_10 00 P2", true)
FusionPro.Composition.SetBodyPageUsage("250_500_75 0_1000NonInsured P1", true)
FusionPro.Composition.SetBodyPageUsage("250_500_75 0_1000NonInsured P2", true)
break;

}

Dan Korn December 5th, 2016 02:47 PM

Re: Suppress specific pages on two values
 
Quote:

Originally Posted by ricky10ss (Post 19410)
Below is the onRecordStart rule I was using but I found out I need to adjust to another field. The switch rule below is turning on the specific pages based off their plan. 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?

Well, first, the code you provided can be reduced, starting with combining cases that have the same results, in several ways. I'd start with 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;
}

And then I would further factor out some of the repeated code like so:
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)
        break;

    case "500":
    case "750":
    case "1000":
        FusionPro.Composition.SetBodyPageUsage("500_750_1000 P1", true)
        FusionPro.Composition.SetBodyPageUsage("500_750_1000 P2", true)
        break;
}

if (Field("PLANOPTION") != "200")
{
    FusionPro.Composition.SetBodyPageUsage("250_500_750_1000NonInsured P1", true)
    FusionPro.Composition.SetBodyPageUsage("250_500_750_1000NonInsured P2", true)
}

Then I think it's pretty obvious how to add the new requirement:
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)
        break;

    case "500":
    case "750":
    case "1000":
        FusionPro.Composition.SetBodyPageUsage("500_750_1000 P1", true)
        FusionPro.Composition.SetBodyPageUsage("500_750_1000 P2", true)
        break;
}

if (Field("PLANOPTION") != "200" && Field("Amount"))
{
    FusionPro.Composition.SetBodyPageUsage("250_500_750_1000NonInsured P1", true)
    FusionPro.Composition.SetBodyPageUsage("250_500_750_1000NonInsured P2", true)
}

I'm pretty sure that will do what you want.

P.S. Further reductions are possible, but the code may be less straightforward. For example:
Code:

var pages = [];

switch (Field("PLANOPTION"))
{
    case "200":
        pages.push("200");
        pages.push("200NonInsured");
        break;

    case "250":
        pages.push("250");
        break;

    case "500":
    case "750":
    case "1000":
        pages.push("500_750_1000");
        break;
}

if (Field("PLANOPTION") != "200" && Field("Amount"))
    pages.push("250_500_750_1000NonInsured");

for (var p in pages)
    for (var i = 1; i <= 2; i++)
        FusionPro.Composition.SetBodyPageUsage(pages[p] + " P" + i, true);


step December 5th, 2016 03:26 PM

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 (Post 19410)
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);
}


ricky10ss December 7th, 2016 07:06 AM

Re: Suppress specific pages on two values
 
Thank you Dan and Step.


All times are GMT -7. The time now is 03:42 AM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.