Jump to content

On Record Start Page Usage-repeating a set of conditions


anthony.bice

Recommended Posts

Hello All,

I've successfully placed a set of 6 conditions as an if/else statement within an On Record Start rule, which returns one of 6 different body pages based on pricing variable entries. I'm calling that a "set" of conditions.

 

I now need to add 2 additional layouts options [unit of Sale] (which will contain 6 pages each, that change with the pricing entries); and, a pull down menu (i.e. 1 For, 2 For, 3 For) with three choices that will call the appropriate set of (6) conditions.

 

I've attempted to add the "Unit of Sale" conditions within all my statements with "Logical Ands", duplicate the set of 6 for the other 2 layouts, and edit the body pages that are being called.

 

Can anyone offer any help with this attempt or direction? Thanks. :-)

 

Here's my stab at containing this in one On Record Start Rule (it validates but doesn't return any preview so far) :

 

 

if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") >= 20)

{

FusionPro.Composition.SetBodyPageUsage("TwentyPlusPricingLayout", true);

}

 

else if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") == 11)

{

FusionPro.Composition.SetBodyPageUsage("DollarAmountEleven", true);

}

 

else if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") >= 10)

{

FusionPro.Composition.SetBodyPageUsage("DoubleDigitPricingLayout", true);

}

 

else if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") == 1)

{

FusionPro.Composition.SetBodyPageUsage("DollarAmountOne", true);

}

 

else if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") == "")

{

FusionPro.Composition.SetBodyPageUsage("LessThanOneDollar", true);

}

 

else (Field("UnitOfSale") == "1 For")

{

FusionPro.Composition.SetBodyPageUsage("SingleDigitPricingLayout", true);

}

 

 

if (Field("UnitOfSale") == "2 For" && Field("DollarAmount") >= 20)

{

FusionPro.Composition.SetBodyPageUsage("2ForTwentyPlusPricing", true);

}

 

else if (Field("UnitOfSale") == "2 For" && Field("DollarAmount") == 11)

{

FusionPro.Composition.SetBodyPageUsage("2ForDollarAmountEleven", true);

}

 

else if (Field("UnitOfSale") == "2 For" && Field("DollarAmount") >= 10)

{

FusionPro.Composition.SetBodyPageUsage("2ForDoubleDigitPricing", true);

}

 

else if (Field("UnitOfSale") == "2 For" && Field("DollarAmount") == 1)

{

FusionPro.Composition.SetBodyPageUsage("2ForDollarAmountOne", true);

}

 

else if (Field("UnitOfSale") == "2 For" && Field("DollarAmount") == "")

{

FusionPro.Composition.SetBodyPageUsage("2ForLessThanOneDollar", true);

}

 

else (Field("UnitOfSale") == "2 For")

{

FusionPro.Composition.SetBodyPageUsage("2ForSingleDigitPricing", true);

}

 

if (Field("UnitOfSale") == "3 For" && Field("DollarAmount") >= 20)

{

FusionPro.Composition.SetBodyPageUsage("3ForTwentyPlusPricing", true);

}

 

else if (Field("UnitOfSale") == "3 For" && Field("DollarAmount") == 11)

{

FusionPro.Composition.SetBodyPageUsage("3ForDollarAmountEleven", true);

}

 

else if (Field("UnitOfSale") == "3 For" && Field("DollarAmount") >= 10)

{

FusionPro.Composition.SetBodyPageUsage("3ForDoubleDigitPricing", true);

}

 

else if (Field("UnitOfSale") == "3 For" && Field("DollarAmount") == 1)

{

FusionPro.Composition.SetBodyPageUsage("3ForDollarAmountOne", true);

}

 

else if (Field("UnitOfSale") == "3 For" && Field("DollarAmount") == "")

{

FusionPro.Composition.SetBodyPageUsage("3ForLessThanOneDollar", true);

}

 

else (Field("UnitOfSale") == "3 For")

{

FusionPro.Composition.SetBodyPageUsage("3ForSingleDigitPricing", true);

}

Link to comment
Share on other sites

if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") >= 20)
{
   FusionPro.Composition.SetBodyPageUsage("TwentyPlusPricingLayout", true);
}

else if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") == 11)
{
   FusionPro.Composition.SetBodyPageUsage("DollarAmountEleven", true);
}

else if (Field("UnitOfSale") == "1 For" && Field("DollarAmount") >= 10)
{
FusionPro.Composition.SetBodyPageUsage("DoubleDigitPricingLayout", true);
}

The first and third tests above contradict each other although I suppose due to the order they are written, JS might allow it so that all numbers greater than 10, but less than 20 skip the first test and then qualify on the 3rd.

else (Field("UnitOfSale") == "1 For")
{
FusionPro.Composition.SetBodyPageUsage("SingleDigi tPricingLayout", true);
}

There shouldn't be a test condition for the final ELSE as this is the catch all for a scenario that is not covered by any preceding IF or ELSE IF.

 

I think in this situation it would be better to use nested IFs like this:

if (Field("UnitOfSale") == "1 For") {
if (Field("DollarAmount") >= 20) {
	FusionPro.Composition.SetBodyPageUsage("TwentyPlusPricingLayout", true);
	}
else if (Field("DollarAmount") == 11) {
	FusionPro.Composition.SetBodyPageUsage("DollarAmountEleven", true);
	}
else if (Field("DollarAmount") >= 10) {
	FusionPro.Composition.SetBodyPageUsage("DoubleDigitPricingLayout", true);
	}
else if (Field("DollarAmount") == 1) {
	FusionPro.Composition.SetBodyPageUsage("DollarAmountOne", true);
	}
else if (Field("DollarAmount") == "") {
	FusionPro.Composition.SetBodyPageUsage("LessThanOneDollar", true);
	}
else {
	FusionPro.Composition.SetBodyPageUsage("SingleDigitPricingLayout", true);
	}
}
else if (Field("UnitOfSale") == "2 For") {
if (Field("DollarAmount") >= 20) {
	FusionPro.Composition.SetBodyPageUsage("2ForTwentyPlusPricing", true);
	}
else if (Field("DollarAmount") == 11) {
	FusionPro.Composition.SetBodyPageUsage("2ForDollarAmountEleven", true);
	}
else if (Field("DollarAmount") >= 10) {
	FusionPro.Composition.SetBodyPageUsage("2ForDoubleDigitPricing", true);
	}
else if (Field("DollarAmount") == 1) {
	FusionPro.Composition.SetBodyPageUsage("2ForDollarAmountOne", true);
	}
else if (Field("DollarAmount") == "") {
	FusionPro.Composition.SetBodyPageUsage("2ForLessThanOneDollar", true);
	}
else {
	FusionPro.Composition.SetBodyPageUsage("2ForSingleDigitPricing", true);
	}
else if (Field("UnitOfSale") == "3 For") {
	if (Field("DollarAmount") >= 20) {
	FusionPro.Composition.SetBodyPageUsage("3ForTwentyPlusPricing", true);
	}
else if (Field("DollarAmount") == 11) {
	FusionPro.Composition.SetBodyPageUsage("3ForDollarAmountEleven", true);
	}
else if (Field("DollarAmount") >= 10) {
	FusionPro.Composition.SetBodyPageUsage("3ForDoubleDigitPricing", true);
	}
else if (Field("DollarAmount") == 1) {
	FusionPro.Composition.SetBodyPageUsage("3ForDollarAmountOne", true);
	}
else if (Field("DollarAmount") == "") {
	FusionPro.Composition.SetBodyPageUsage("3ForLessThanOneDollar", true);
	}
else {
	FusionPro.Composition.SetBodyPageUsage("3ForSingleDigitPricing", true);
	}
}

Link to comment
Share on other sites

If you can change the names of your pages so they are more standardized (remove the word "layout" from the "1 For" page names and add the word "1For" to the beginning of those page names which would bring them more inline with the "2For" and "3For" pages) you could use a simplified function like this:

 

var pageName;
var dollarAmt = Field("DollarAmount");
var unitOfSale = Field("UnitOfSale").replace(" ","");

if (dollarAmt>=20){
pageName = "TwentyPlusPricing";
}else if (dollarAmt==11){
pageName = "DollarAmountEleven";
}else if (dollarAmt>=10){
pageName = "DoubleDigitPricing";
}else if (dollarAmt==1){
pageName = "DollarAmountOne";
}else{
pageName = "LessThanOneDollar";
}
FusionPro.Composition.SetBodyPageUsage(unitOfSale + pageName, true);

 

I also noticed that given the current setup, prices between 2 and 9 are going to return "LessThanOneDollar".

 

EDIT: Or rather, prices between 2 and 9 won't return a value given the original setup but would give "LessThanOneDollar" in mine. Just change it to >=1 in that test.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...