View Single Post
  #7  
Old February 4th, 2016, 04:12 PM
JPalchak JPalchak is offline
Junior Community Member
 
Join Date: Jan 2016
Posts: 10
Default Re: Composing Several Non-Sequential Records

Quote:
Originally Posted by step View Post
You can do this by creating an array of records you want to compose and then comparing the inputRecordNumber against that array to determine whether a record should be suppressed or not:
Code:
var records = [1, 8,'4-6']; // Records to compose

records = records.map(function(s){ s = String(s); var [a,b] = s.split('-'); a = Int(a); b = Int(b || a); s = [a]; while (a < b) s.push(++a); return s.join('|'); }).join('|');

FusionPro.Composition.composeThisRecord = new RegExp(records, '').test(FusionPro.Composition.inputRecordNumber);
Note that the order doesn't matter and that you specify a range of records as long as the range is a string (within quotes) otherwise the numbers will just be subtracted. The above code would compose records 1,4,5,6, and 8.

Alternatively it seems like you could only compose records that have a unique back by setting up a global array:
Code:
var backs = [];
And then comparing the back to be used for a specific record to the array. If it's not in the array, that means it's unique so compose the record and push it into the array. If it exists in the array, then you can skip that record because you've already composed a record with that back. To me, that seems easier than searching through your data for records to build a "proof" list but I may be missing something.
Code:
var back = Field("Back"); // Field to determine which back page to turn on

if (backs.indexOf(back) > -1)
    FusionPro.Composition.composeThisRecord = false;
backs.push(back);
Thanks for the help outlining this! I used the first method by declaring the records manually in the array fine however when I try this method I get a fatal error when trying to compose:

Code:
A body page does not have master page assigned.
A blank page is emitted since no record is composed properly.

dlpdfdocwritepdf, progress "Doc->PageCount is zero", error: Bad parameter.

PDF Library Document Write Error: Bad parameter.

pdf_om_WriteDoc, dtl_pdf_WritePdf returned "-2"

Job aborted with error.
Is this just because I don't have a blank "null" page set-up if there isn't a record for a body?
Reply With Quote