Go Back   MarcomCentral (PTI) and FusionPro User Communities > Support > Issues, Questions, Etc.

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old August 3rd, 2017, 04:07 PM
Landisa's Avatar
Landisa Landisa is offline
Junior Community Member
 
Join Date: Jun 2014
Location: United States
Posts: 31
Default Complex Chunking Based on Fields and Record Number

So we are trying to find a better way to run several hundred different coupon stacks. The customer wants the coupons stacked in "books" based on the number of coupons per book.

Here are the codes I have:

OnJobStart
Code:
FusionPro.Composition.chunksBreakStacks = true;
OnRecordStart
Code:
var jobNumber = Field("Job #") + "_" + Field("BMA Name");
var jobExtension = "." + (FusionPro.Composition.outputFormatExtension || "pdf");

if (FieldChanged("BMA Name") && FusionPro.Composition.repeatRecordNumber == 1)
    FusionPro.Composition.OpenNewOutputFile(jobNumber + jobExtension);
couponNumber
Code:
var strNumber = "<b><z newsize=10>N<z newsize=14><u><superscript>o</superscript></u><z newsize=12>&nbsp;</b>";
var bookCount = Field("# of books");
var couponPerBook = Field("# of coupons/book"); 

FusionPro.Composition.composeAllRecords = false; 
FusionPro.Composition.startRecordNumber = Field("start #"); 
FusionPro.Composition.endRecordNumber = Field("end #"); 
FusionPro.Composition.repeatRecordCount = Field("# of coupons"); 

return strNumber + FormatNumber ("0000", FusionPro.Composition.recordNumberInChunk);
This works great for stacking our coupons for each Ranch.
However, we now need to use the # of coupons/book to break up each part into a new book.
Example: Currently we see
HTML Code:
Job#_Ranch1.pdf     (4000 coupons 1-4000)
Job#_Ranch2.pdf     (6000 coupons 1-6000)
What we are looking for are smaller chunks based on number of records per book and number of books or total number of coupons.
Example: We want to see
Code:
Job#_Ranch1_Book1     (2000 coupons 1-2000)
Job#_Ranch1_Book2     (2000 coupons 2001-4000)
Job#_Ranch2_Book1     (1000 coupons 1-1000)
Job#_Ranch2_Book2     (1000 coupons 1001-2000)
Job#_Ranch2_Book3     (1000 coupons 2001-3000)
Job#_Ranch2_Book4     (1000 coupons 3001-4000)
Job#_Ranch2_Book5     (1000 coupons 4001-5000)
Job#_Ranch2_Book6     (1000 coupons 5001-6000)
I have tried a few things, including for loops, extra if statements and while loops. So far I have been unsuccessful at getting the result we need.

I am assuming we need a variable "bookCount" to increase after each set so it doesn't overwrite the previous set.

Attached is the original code before the OnRecordStart was updated for you to work with.

Suggestions?
Attached Files
File Type: zip BMA Sample Coupons.zip (10.7 KB, 12 views)
__________________
Audra Landis
Computer Systems Admin

VDP Producer v10.0.3
Windows 7 / Windows 10
Acrobat Pro DC (2015.010.20056)
Reply With Quote
  #2  
Old August 3rd, 2017, 06:00 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,369
Default Re: Complex Chunking Based on Fields and Record Number

Quote:
Originally Posted by Landisa View Post
What we are looking for are smaller chunks based on number of records per book and number of books or total number of coupons.
Example: We want to see
Code:
Job#_Ranch1_Book1     (2000 coupons 1-2000)
Job#_Ranch1_Book2     (2000 coupons 2001-4000)
Job#_Ranch2_Book1     (1000 coupons 1-1000)
Job#_Ranch2_Book2     (1000 coupons 1001-2000)
Job#_Ranch2_Book3     (1000 coupons 2001-3000)
Job#_Ranch2_Book4     (1000 coupons 3001-4000)
Job#_Ranch2_Book5     (1000 coupons 4001-5000)
Job#_Ranch2_Book6     (1000 coupons 5001-6000)
So you want to always break up the output into chunks of 1000 coupons? If it's always a fixed number, like 1000, then you can just go into the Composition Settings, on the Output tab, check the "Output to multiple files" box, and set the number of records to 1000.

Or is the number of coupons per chunk variable? If so, then you just need to change the condition here:
Code:
if (FieldChanged("BMA Name") && FusionPro.Composition.repeatRecordNumber == 1)
    FusionPro.Composition.OpenNewOutputFile(jobNumber + jobExtension);
To something like this:
Code:
if (FieldChanged("BMA Name") || FusionPro.Composition.repeatRecordNumber % couponPerBook == 1)
{
    var couponPerBook = Field("# of coupons/book");
    var jobNumber = Field("Job #") + "_" + Field("BMA Name") + "_Book" + Int((FusionPro.Composition.repeatRecordNumber-1) / couponPerBook);
    var jobExtension = "." + (FusionPro.Composition.outputFormatExtension || "pdf");
    FusionPro.Composition.OpenNewOutputFile(jobNumber + jobExtension);
}
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old August 4th, 2017, 08:11 AM
Landisa's Avatar
Landisa Landisa is offline
Junior Community Member
 
Join Date: Jun 2014
Location: United States
Posts: 31
Default Re: Complex Chunking Based on Fields and Record Number

Quote:
Originally Posted by Dan Korn View Post
Or is the number of coupons per chunk variable? If so, then you just need to change the condition here:
Code:
if (FieldChanged("BMA Name") && FusionPro.Composition.repeatRecordNumber == 1)
    FusionPro.Composition.OpenNewOutputFile(jobNumber + jobExtension);
To something like this:
Code:
if (FieldChanged("BMA Name") || FusionPro.Composition.repeatRecordNumber % couponPerBook == 1)
{
    var couponPerBook = Field("# of coupons/book");
    var jobNumber = Field("Job #") + "_" + Field("BMA Name") + "_Book" + Int((FusionPro.Composition.repeatRecordNumber-1) / couponPerBook);
    var jobExtension = "." + (FusionPro.Composition.outputFormatExtension || "pdf");
    FusionPro.Composition.OpenNewOutputFile(jobNumber + jobExtension);
}
Yes, the chunks are a variable. I was happy with how this worked but the coupons don't continue the count after the book is output.

So now I see:
Code:
Job#_Ranch1_Book0     2000 coupons     (1-2000)
Job#_Ranch1_Book1     2000 coupons     (1-2000)
What I was hoping for was to continue the numbering sequence:
Code:
Job#_Ranch1_Book0     2000 coupons     (1-2000)
Job#_Ranch1_Book1     2000 coupons     (2001-4000)
Is there a way to keep the numbering sequential?
__________________
Audra Landis
Computer Systems Admin

VDP Producer v10.0.3
Windows 7 / Windows 10
Acrobat Pro DC (2015.010.20056)
Reply With Quote
  #4  
Old August 4th, 2017, 09:24 AM
Landisa's Avatar
Landisa Landisa is offline
Junior Community Member
 
Join Date: Jun 2014
Location: United States
Posts: 31
Default Re: Complex Chunking Based on Fields and Record Number

Nevermind! I just had to eat some breakfast.

I used your book separating method and changed the couponNumber rule:

Old Rule
Code:
var strNumber = "<b><z newsize=10>N<z newsize=14><u><superscript>o</superscript></u><z newsize=12>&nbsp;</b>";

FusionPro.Composition.composeAllRecords = false; 
FusionPro.Composition.startRecordNumber = Field("start #"); 
FusionPro.Composition.endRecordNumber = Field("# of coupons"); 
FusionPro.Composition.repeatRecordCount = Field("# of coupons");

return strNumber + FormatNumber ("0000", FusionPro.Composition.recordNumberInChunk);
New Rule
Code:
var strNumber = "<b><z newsize=10>N<z newsize=14><u><superscript>o</superscript></u><z newsize=12>&nbsp;</b>";

FusionPro.Composition.composeAllRecords = false; 
FusionPro.Composition.startRecordNumber = Field("start #"); 
FusionPro.Composition.endRecordNumber = Field("# of coupons"); 
FusionPro.Composition.repeatRecordCount = Field("# of coupons");

return strNumber + FormatNumber ("0000", FusionPro.Composition.repeatRecordNumber);
By changing it from recordNumberInChunk to repeatRecordNumber, it kept the sequence set number per Ranch but continued to break correctly between books.

Thanks! ^^,
__________________
Audra Landis
Computer Systems Admin

VDP Producer v10.0.3
Windows 7 / Windows 10
Acrobat Pro DC (2015.010.20056)
Reply With Quote
Reply

Tags
chunk, coupons, record number, repeatrecordnumber

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:37 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.