Jump to content

Recommended Posts

Posted

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

Posted

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.

Posted
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.

  • 1 year later...
Posted
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")

Posted
 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.

 

 

 

Posted

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

Posted

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"));

 

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...