mjlongo Posted March 7, 2017 Share Posted March 7, 2017 Hello, our customer will be providing a document to use that may contain 100's or 1000's of pages. The job will require that only select pages as well as a separate variable page will be used for each record. Is there a way to quickly set all of the pages to unused? I certainly will not want to go mark every page as unused manually. Thanks! Quote Link to comment Share on other sites More sharing options...
step Posted March 7, 2017 Share Posted March 7, 2017 (edited) One way to do that is to add this to your OnRecordStart callback rule: // List of pages that should be enabled in your template var enabledPages = [ 4, 10, 11, ]; var totalPages = 1000; // Total number of pages in your template for (var page = 1; page <= totalPages; page++) { FusionPro.Composition.SetBodyPageUsage(page, enabledPages.indexOf(page) > -1); } You can also get away with not defining the total number of pages in your document by using this code instead: // List of pages that should be enabled in your template var enabledPages = [ 4, 10, 11, ]; var page = 0; while (++page && !FusionPro.inValidation) { try { FusionPro.Composition.SetBodyPageUsage(page, enabledPages.indexOf(page) > -1); } catch(e) { break; } } Edited March 7, 2017 by step Forgot to define a variable Quote Link to comment Share on other sites More sharing options...
mjlongo Posted March 7, 2017 Author Share Posted March 7, 2017 Step, thank you for that response. That sets me off in the right direction. I did run into one problem however. The enabledPages variable that is being set at the beginning does not seem to want to take in the field. for example, I was looking to do something like this: enabledPages = [field("record number"), 101] So that page "record number" (maybe equals 1) would be the valid page for that record as well as page 101. The next record in the document might end up calling out page 5 and so on. I hope that makes sense. Quote Link to comment Share on other sites More sharing options...
step Posted March 7, 2017 Share Posted March 7, 2017 The enabledPages variable that is being set at the beginning does not seem to want to take in the field. Not sure what you mean by that. Are you getting an error that gives you that impression? Could you share it? for example, I was looking to do something like this: enabledPages = [field("record number"), 101] Are you entering it exactly like that? If so, you need to capitalize the "field" function so that it pulls in your field value correctly. The only other thing I could think that you might want to try is ensuring that all of your variables are of the same type. In my example, all of the numbers in the array were integers being compared to integers. This might help: // List of pages that should be enabled in your template var enabledPages = [[color="red"]Field[/color]("record number"), 101][color="Red"].map(Int);[/color] var page = 0; while (++page && !FusionPro.inValidation) { try { FusionPro.Composition.SetBodyPageUsage(page, enabledPages.indexOf(page) > -1); } catch(e) { break; } } Quote Link to comment Share on other sites More sharing options...
mjlongo Posted March 7, 2017 Author Share Posted March 7, 2017 Step, the .map(Int) part is all that I needed. The job works now. Thanks!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.