Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library


Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old April 30th, 2020, 04:53 PM
mclarke mclarke is offline
Forum n00b
Join Date: Apr 2020
Location: Upstate NY
Posts: 4
Question Help with complex composition


I am *very* new to FusionPro and somewhat of a beginner in Javascript, but I have to come up with a demo for a customer creating one of their more complex products (at least to me) in FusionPro to show them it's merits in their daily production.

The product is raffle ticket books. Each book has a personalized front cover, dual numbered tickets with the amount of tickets in each book set at time of order (variable) and a back cover. The cover of each book also has to have "Book x of y" numbering on it.

So, I have a calculation for the total number of books, some "setbodypageusage" loops and then have to produce them as both one file for each book and one file for each order (not at the same time - two different production runs).

The customer wants a totally hands-off production run (we're going to be looking at FusionPro Producer if I can get this to work manually) with each order a separate line in the data file.

I've watched all the training videos, read the entire Rules guide and the User Guide section on rules, and I still can't figure out how to setup the loops.

This is what I've managed to come up with so far:


FusionPro.Composition.chunksBreakStacks = true;


FusionPro.Composition.SetBodyPageUsage(Front, true)

var jobNumber = Field("CompanyName") + "_" + Field("TotalTickets");
var totalBooks = 0;
var ticketsPerBook = Field("TicketsPerBook");
var jobExtension = "." + (FusionPro.Composition.outputFormatExtension || "pdf");

if (FieldChanged("Companyname") || FusionPro.Composition.repeatRecordNumber % couponPerBook == 1)
    var jobNumber = Field("CompanyName") + "_" + Field("TotalTickets") + "_Book" + Int((FusionPro.Composition.repeatRecordNumber-1) / couponPerBook);
    var jobExtension = "." + (FusionPro.Composition.outputFormatExtension || "pdf");
    FusionPro.Composition.OpenNewOutputFile(jobNumber + jobExtension);

Ticket Number Rule

FusionPro.Composition.composeAllRecords = false; 
FusionPro.Composition.startRecordNumber = Field("StartNumber"); 
FusionPro.Composition.endRecordNumber = Field("TotalTickets"); 
FusionPro.Composition.repeatRecordCount = Field("TotalTickets");

return FormatNumber ("####", FusionPro.Composition.repeatRecordNumber);

Book Number Rule

var bookTotal = Field("TotalTickets") / Field("TicketsPerBook");

FusionPro.Composition.composeAllRecords = false; 
FusionPro.Composition.startRecordNumber = Field("StartNumber"); 
FusionPro.Composition.endRecordNumber = bookTotal; 
FusionPro.Composition.repeatRecordCount = bookTotal;

return FormatNumber ("####", FusionPro.Composition.repeatRecordNumber);

Book Total Rule

var bookTotal = Field("TotalTickets") / Field("TicketsPerBook");

return bookTotal

The sample data is as follows:

CompanyName,TotalTickets,TicketsPerBook,Date,Locat ion,FirstPrize,SecondPrize,ThirdPrize,Price,MultPr ice,StartNumber
ABC Company,1500,10,"July 3, 2020","123 Main Street, Anytown","40"" Smart TV",A Case of Mixed Wine,$25 Gas Card,5,20,1
Acme Widgets,2500,25,"August 14, 2020","895 Smith Place, Toytown",Weekend for Two in Las Vegas,"32"" Smart TV",$100 Gift Card,5,20,1
Spacely Sprockets,500,5,"September 7, 2020","999 Jon Street, Cape End",Entertainment Gift Basket,$25 Gas Card,$10 Starbucks Card,1,3,1

Any help will be greatly appreciated!!

Reply With Quote

loops, variable pages

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 11:02 AM.

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