PDA

View Full Version : File output records based on data field


KatJones
December 19th, 2012, 01:11 PM
Here is the details:
I have 1 large data file. Within that data file I have 20 versions. Each version has different quantities.

The problem:
I need to output SEPARATE .pdfs based on each version... with each each PDF named what version it is tagged to.

Example:
A01 has 33214 records
A02 has 26102 records...etc.

I need a PDF named A01.pdf that has 33214 records, and I will need another PDF named A02.pdf with 26102 records and so on....

I am certain there is a callback rule that can be created, but my javascript/script writing skills is minimal to none.

Dan Korn
December 19th, 2012, 01:17 PM
In OnRecordStart:
if (FieldChanged("YourFieldName"))
FusionPro.Composition.OpenNewOutputFile(Field("YourFieldName") +
"." + FusionPro.Composition.outputFormatExtension);

KatJones
December 19th, 2012, 01:30 PM
In OnRecordStart:
if (FieldChanged("YourFieldName"))
FusionPro.Composition.OpenNewOutputFile(Field("YourFieldName") +
"." + FusionPro.Composition.outputFormatExtension);

It says that the FieldChange is not defined once I changed the "yourfieldname".

Dan Korn
December 19th, 2012, 01:51 PM
It says that the FieldChange is not defined once I changed the "yourfieldname".
Sorry, you didn't say what version of FusionPro you're using. This requires FusionPro 8.

KatJones
December 19th, 2012, 01:54 PM
Ah! I believe that may be the problem. We are operating on a older version of FusionPro. Is there a code for older versions? We are on 7.2

Dan Korn
December 19th, 2012, 02:00 PM
Ah! I believe that may be the problem. We are operating on a older version of FusionPro. Is there a code for older versions? We are on 7.2
No, the ability to compose to multiple output files, each of which contains a different number of output records (what we sometimes call "arbitrary chunking") is a new feature in FusionPro 8. It can't be done in 7.2. The only thing you can do with your version is to break up the input file and do multiple compositions.

In general, it's best to specify what version you're using when asking a question, as my signature notes.

KatJones
March 25th, 2014, 12:37 PM
Hello,

Following back up on this. We now have upgraded to 9.1.0. On output do I need to check anything? Like the output to multiple files or anything. Im not seeing my files output as separate files based on the field change.

I should mention that I used an imposition file with this. Does that matter?

Dan Korn
March 25th, 2014, 03:43 PM
Hello,

Following back up on this. We now have upgraded to 9.1.0. On output do I need to check anything? Like the output to multiple files or anything. Im not seeing my files output as separate files based on the field change.
The only thing you might need to do is turn off the "Output to multiple files" setting on the Output tab of the Composition Settings, if you had that checked. That sets "static chunking," where each output file (chunk) is the same number of records, but you're trying to use "dynamic chunking," where each output file has an arbitrary number of records. Generally, you want one or the other.
I should mention that I used an imposition file with this. Does that matter?
Yes, the imposition could be the problem. Are you doing stacked imposition? If so, then FusionPro wants to defer the chunk break (start of a new output file) until the next stack break (start of a new imposed stack) by default. You can modify this behavior by setting this in the OnJobStart rule:
FusionPro.Composition.chunksBreakStacks = true;Although, before doing that, I would first disable imposition just to see if the chunking (multiple output files) is working the way you want without imposition.

KatJones
March 26th, 2014, 06:49 AM
I have tried this with imposition (infinite stack checked and without), without imposition. I didn't have the output to multiple files checked at all. It is still producing one output.

:confused::confused::confused:

Dan Korn
March 26th, 2014, 09:36 AM
I have tried this with imposition (infinite stack checked and without), without imposition. I didn't have the output to multiple files checked at all. It is still producing one output.
Okay, then maybe the rule is not written correctly. You are using some code similar to what I posted in your OnRecordStart rule, right? If you post the rule syntax here, I might be able to figure out what's wrong with it. Otherwise, I could just keep guessing, but my ESP isn't working well today.

You could always try something like this:
if (FieldChanged("<your field name>"))
Print("The field changed!")Then look in the composition log (.msg) file to see if that message is printed. If it's not, then you either have the wrong thing there in your "if" condition, or the field value is not actually changing.

Here is what the OnRecordStart rule would look like in the Cell Phone tutorial job installed with FusionPro:
if (FieldChanged("Lname"))
FusionPro.Composition.OpenNewOutputFile(Field("LName") +
"." + FusionPro.Composition.outputFormatExtension);