web2print Posted March 1, 2018 Share Posted March 1, 2018 Hello, I am in need of some guidance to get body pages to populate based on a value in an external data file. I have two different body pages that will be used, a black one and a white one. One or the other will populate based on the users location and the logo for that location. If the logo looks better on a black background, i want them to get the black version. Same thing with the white version. The EDF will be as simple as: Location --------- Version Home Depot ------- White Lowes -------------- White Menards ------------ Black Etc... etc... So when they self register, they are going to be selecting their location and then based on that decision, all of the products in the catalog will divert to either white background or black background. What would the "onrecordstart" rule look like within each product? I understand how to get information to populate from an external data file but i am just not sure how to "FusionPro.Composition.SetBodyPageUsage" from an external data file. It needs to search/find the value for "version" in the EDF somehow and then set the body page based on that but i am just not sure how to spell that out in a rule. Thank you Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted March 1, 2018 Share Posted March 1, 2018 Assuming your pages are set to unused and named "Black" and "White", you can do something like this: var Location = Field("Location"); // as selected by the end user var XDF = new ExternalDataFileEx("YourExternalDataFileName"); var XDF_rec = XDF.FindRecord("Location", Location); var Version = XDF.GetFieldValue(XDF_rec, "Version ")) || "White"; FusionPro.Composition.SetBodyPageUsage(Version, true); Or, more succinctly: var XDF = new ExternalDataFileEx("YourExternalDataFileName"); var Version = XDF.GetFieldValue(XDF.FindRecord("Location", Field("Location")), "Version ")) || "White"; FusionPro.Composition.SetBodyPageUsage(Version, true); Although, you don't necessarily need to use a whole different Body page. You could just put an empty named text frame at the lowest layer on one body page, and set its background color programmatically, like so: var XDF = new ExternalDataFileEx("YourExternalDataFileName"); var Color = XDF.GetFieldValue(XDF.FindRecord("Location", Field("Location")), "Version ")) || "White"; FindTextFrame("background").fillColorName = Color; This, of course, could all be done without an XDF file as well: var Color = "White"; switch (ToLower(Field("Location")) { case "menards": case "other name here": case "etc.": Color = "Black"; } // Then either call out a page or set a frame fill or something based on that color name. Or even: var BlackBackgroundLocations = ["menards", "other name here", "etc."]; var Color = BlackBackgroundLocations.indexOf(ToLower(Field("Location")) >= 0 ? "Black" : "White"; // Then either call out a page or set a frame fill or something based on that color name. Quote Link to comment Share on other sites More sharing options...
web2print Posted March 1, 2018 Author Share Posted March 1, 2018 You're the man, Dan! Thank you for your help. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.