hopkinsprinting Posted November 16, 2023 Posted November 16, 2023 Hi everyone, I have a letter that is 4 versions. The base art is the same across all 4 versions, it's just the letter that is variable (and each letter has variables within the paragraphs of text). Normally, I would just process this as 4 versions but because this will mail, the associated mailing lists have been combined into one list. In looking at the documentation for FP, it looks like maybe objects can be hidden/shown with a JavaScript rule but I am not able to make sense of it. As I have no experience with JavaScript, could someone please provide the code to achieve this? Thank you so much, jm Quote
ThomasLewis Posted November 16, 2023 Posted November 16, 2023 One way to do this is stack all the text frames on top of each other and turn them all off via script. Then turn on the one that's needed. Make a new Event rule for OnRecordStart and add this: FindTextFrame("Name1").suppress = true; FindTextFrame("Name2").suppress = true; FindTextFrame("Name3").suppress = true; FindTextFrame("Name4").suppress = true; if (Field("Version") == "Ver1") FindTextFrame("Name1").suppress = false; else if (Field("Version") == "Ver2") FindTextFrame("Name2").suppress = false; else if (Field("Version") == "Ver3") FindTextFrame("Name3").suppress = false; else if (Field("Version") == "Ver4") FindTextFrame("Name4").suppress = false; You need to name your text frames appropriately and swap out the names in the script with whatever is in your document. The "Ver1", "Ver2", etc values should be whatever value would be in your Version field to determine which frame gets turned on. If this doesn't work out for you, I would suggest posting your template and sending a sample data file that doesn't contain anything personal in it. Quote
Dan Korn Posted November 21, 2023 Posted November 21, 2023 On 11/16/2023 at 4:22 PM, ThomasLewis said: One way to do this is stack all the text frames on top of each other and turn them all off via script. Then turn on the one that's needed. Make a new Event rule for OnRecordStart and add this: FindTextFrame("Name1").suppress = true; FindTextFrame("Name2").suppress = true; FindTextFrame("Name3").suppress = true; FindTextFrame("Name4").suppress = true; if (Field("Version") == "Ver1") FindTextFrame("Name1").suppress = false; else if (Field("Version") == "Ver2") FindTextFrame("Name2").suppress = false; else if (Field("Version") == "Ver3") FindTextFrame("Name3").suppress = false; else if (Field("Version") == "Ver4") FindTextFrame("Name4").suppress = false; You need to name your text frames appropriately and swap out the names in the script with whatever is in your document. The "Ver1", "Ver2", etc values should be whatever value would be in your Version field to determine which frame gets turned on. If this doesn't work out for you, I would suggest posting your template and sending a sample data file that doesn't contain anything personal in it. This is equivalent to: for (var i = 1; i <= 4; i++) FindTextFrame("Name" + i).suppress = (Field("Version") != "Ver" + i); If you have groups of frames that you want to show and hide, you can set up named frame groups in the Document Overview palette and call HideFrameGroup or ShowFrameGroup. Quote
hopkinsprinting Posted November 27, 2023 Author Posted November 27, 2023 Hi Thomas and Dan, Your suggestion worked like a charm! THANK YOU SO MUCH!!! Best regards, jm Quote
smattos Posted March 25 Posted March 25 On 11/21/2023 at 11:10 AM, Dan Korn said: This is equivalent to: for (var i = 1; i <= 4; i++) FindTextFrame("Name" + i).suppress = (Field("Version") != "Ver" + i); If you have groups of frames that you want to show and hide, you can set up named frame groups in the Document Overview palette and call HideFrameGroup or ShowFrameGroup. Can you expand on this with using Groups? What is the full coding to use to hide/show Groups under the Document Overview. Something like this... ShowFrameGroup ("Spanish") if (Field("LANGUAGE") = "2") else ShowFrameGroup ("English") Quote
Douglas Cogan Posted March 25 Posted March 25 if (Field("LANGUAGE") == "2") ShowFrameGroup ("Spanish") else ShowFrameGroup ("English") I think this is what you have in mind. There is a sample we ship with the product. It is the Mailer sample which you can get to with the menu option FusionPro->Documentation->Tutorials. Open the PDF file Jensen_TrifoldMailer-Groups.pdf The User Guide explains this in detail in the section about Groups on how to set up the group and turn it on and off. But basically you use the Group palette to associate the frames together in one group and use one function call to turn them all on/off with one call. Quote
smattos Posted March 26 Posted March 26 Thank you Douglas Cogan! This and the Mailer sample you mentioned was very helpful! Quote
hopkinsprinting Posted April 2 Author Posted April 2 Hi Everyone, I need to revisit this for a minute. I have a project that has two versions however for each version, there are two variable text frames that need to be shown. The code I tried is: FindTextFrame("English Header").suppress = true; FindTextFrame("English Body").suppress = true; FindTextFrame("Spanish Header").suppress = true; FindTextFrame("Spanish Body").suppress = true; if (Field("Version") == "English") FindTextFrame("English Header").suppress = false; FindTextFrame("English Body").suppress = false; else if (Field("Version") == "Spanish") FindTextFrame("Spanish Header").suppress = false; FindTextFrame("Spanish Body").suppress = false; FusionPro does not like the line of code starting with “else if”. What is the correct code for this? Thank you, hp Quote
Dan Korn Posted April 2 Posted April 2 In JavaScript, if you want multiple statements to be affected by a conditional statement such as "if" or "for" or "while", you have to use curly brackets to put them into a statement block. So you want to do do this: FindTextFrame("English Header").suppress = true; FindTextFrame("English Body").suppress = true; FindTextFrame("Spanish Header").suppress = true; FindTextFrame("Spanish Body").suppress = true; if (Field("Version") == "English") { FindTextFrame("English Header").suppress = false; FindTextFrame("English Body").suppress = false; } else if (Field("Version") == "Spanish") { FindTextFrame("Spanish Header").suppress = false; FindTextFrame("Spanish Body").suppress = false; } Though all of that can be simplified/reduced to this: FindTextFrame("English Header").suppress = Field("Version") != "English"; FindTextFrame("English Body").suppress = Field("Version") != "English"; FindTextFrame("Spanish Header").suppress = Field("Version") != "Spanish"; FindTextFrame("Spanish Body").suppress = Field("Version") != "Spanish"; Or further generalized if you have more languages. But you could also do this even more simply, but putting the frames into groups, with the Groups tab on the Document Overview palette, then the entire rule could be just this: ShowFrameGroup("English", Field("Version") == "English")); ShowFrameGroup("Spanish", Field("Version") == "Spanish")); Quote
hopkinsprinting Posted April 2 Author Posted April 2 Ah ha! Thank you for the info! 🙂 Best regards, hp Quote
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.