anthony.bice Posted August 19, 2009 Share Posted August 19, 2009 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 More sharing options...
esmith Posted August 19, 2009 Share Posted August 19, 2009 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 More sharing options...
anthony.bice Posted August 19, 2009 Author Share Posted August 19, 2009 Thank You Mr. Smith, I'll put this approach to use at once and let you know. Thanks very much for the quick reply, you rock. Anthony Bice Link to comment Share on other sites More sharing options...
tobarstep Posted August 19, 2009 Share Posted August 19, 2009 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 More sharing options...
anthony.bice Posted August 19, 2009 Author Share Posted August 19, 2009 Thank You Both, I am working with esmith's "Nested If" approach now. I will digest tobarstep's Fuction soon. Thanks all so much. I'm trying to slowly understand all points and implement myself rather than copying/pasting your offered solutions. Link to comment Share on other sites More sharing options...
esmith Posted August 19, 2009 Share Posted August 19, 2009 Touché tobartep. I knew a more concise answer lay somewhere amidst all the repetitive words in the preceding solutions! Link to comment Share on other sites More sharing options...
tobarstep Posted August 19, 2009 Share Posted August 19, 2009 Oh, please don't think I was trying to one-up you I think both approaches will work the same. It's more of a personal preference thing; I like to use variables as much as possible. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.