Jump to content

Split output file according to first 3 digits of zip code


Recommended Posts

I think I might eventually figure this out on my own but I'm wussing out and asking for help.

I have a weekly mailer which can only have the bulk rate postage indicia on zip codes beginning with 980, 981, or 982.  Everything else gets metered.  My people have been manually separating the data and making two compositions.  I want to make a callback rule that will start a new file when it hits a range of records with zip codes begining with one of those 3 numbers.  Since the data file is sorted on the zip code I'd hoped to get 3 output files, 1 from record 1 up to the first record with a zip of 980, then one for that set of zips, and one with all zips from 983 and beyond.

I've tried the code below but I think it's ignoring the slice command.  All I get is a separate output file for each zip code, sometimes a couple dozen.  I'm not well versed with Javascript, VBA is my bread and butter, so any alternative suggestions are welcome.  We're on FP Creator 13, desktop not server.

var Z = Field("ZipCode");

var first3 = Z.slice(0,3);

    if (FieldChanged("ZipCode")) && (first3 == "980" || "981" || "982");

    FusionPro.Composition.OpenNewOutputFile(Field("ZipCode")) + ".pdf";

Link to comment
Share on other sites

Your syntax is a bit off. When you do evaluations you have to make sure your parentheses close in the right spots and evaluate each one like this:

if (FieldChanged("ZipCode") && (first3 == "980" || first3 == "981" || first3 == "982"))

or use an array if you have a bunch of different values

if (FieldChanged("ZipCode") && ["980", "981", "982"].indexOf(first3) > -1)

Additionally, the entire name of the output file has to be part of the OpenNewOutputFile function like so:

FusionPro.Composition.OpenNewOutputFile(Field("ZipCode") + ".pdf");

 

  • Like 1
Link to comment
Share on other sites

Thanks.  That did make it so I'm getting getting new files only for those zips that I want.  However, because it is naming them for the current zip code each record overwrites the previous record.  I end up with files for each unique zip code, (98004, 98005,98006, etc.) but each file has only one record even though there should be hundreds for each zip code.

Ideally what I was hoping for was 3 files.  The first a file for all zips up to the first with 980, followed by one with all 980, 981, and 982 zips, followed by all the remaining records.

On a related note.  When I was setting this up I created a template in InDesign with 1 variable text frame, and 1 variable graphic frame.  A few days later when I was going back to the InDesign file to demonstrate/train a person on how to set something up I can no longer find the FusionPro palette.  Have you ever heard of that just disappearing?

Link to comment
Share on other sites

It works perfectly fine for me. I've attached a sample you can run and check against your code.

Also, I do not use InDesign to setup templates nor do I have the plugin installed. I setup everything from blank pages in Acrobat and just bring the artwork in as a resource, so I wouldn't be able to answer you on the missing palette. You may need to email support on that one.

split-zips-test.zip

Link to comment
Share on other sites

On 7/18/2024 at 11:01 AM, DaveYeag said:

On a related note.  When I was setting this up I created a template in InDesign with 1 variable text frame, and 1 variable graphic frame.  A few days later when I was going back to the InDesign file to demonstrate/train a person on how to set something up I can no longer find the FusionPro palette.  Have you ever heard of that just disappearing?

This isn't really a related question, and should go into a new thread to avoid muddying the two questions.

Have you tried going into the Window menu in InDesign and selecting the FusionPro menu item?

Or, perhaps your version of InDesign was updated, in which case you need a new plug-in.  If you're on Windows, you can run InstallPlugs.exe from "C:\Program Files\PTI\FusionPro" (or wherever it was installed).  On Mac, you can re-run the FusionPro installer.

Link to comment
Share on other sites

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