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

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 23rd, 2012, 05:44 PM
juliazo juliazo is offline
Junior Community Member
 
Join Date: Jun 2012
Posts: 22
Exclamation Problem activating pages with SetBodyPageUsage

Hi again...

Trying to activate pages on demand, but the callback rule (OnJobStart) gives me an error message when composing:

OnJobStart, line 1: Error: In Field(), no data source defined or data could not be loaded

The data source is defined, as the composition itself works, it's just that the pages I want to activate/deactivate don't quite work as expected.

Here's my callback rule:

Quote:
if (Field("Style") == "A1")
{
if (Field("PageCount") == "8")
{
FusionPro.Composition.SetBodyPageUsage("A1_1",true );
}
if (Field("PageCount") == "16")
{
FusionPro.Composition.SetBodyPageUsage("A1_1",true );
FusionPro.Composition.SetBodyPageUsage("A1_2",true );
}
if (Field("PageCount") == "24")
{
FusionPro.Composition.SetBodyPageUsage("A1_1",true );
FusionPro.Composition.SetBodyPageUsage("A1_2",true );
FusionPro.Composition.SetBodyPageUsage("A1_3",true );
}
if (Field("PageCount") == "32")
{
FusionPro.Composition.SetBodyPageUsage("A1_1",true );
FusionPro.Composition.SetBodyPageUsage("A1_2",true );
FusionPro.Composition.SetBodyPageUsage("A1_3",true );
FusionPro.Composition.SetBodyPageUsage("A1_4",true );
}
if (Field("PageCount") == "40")
{
FusionPro.Composition.SetBodyPageUsage("A1_1",true );
FusionPro.Composition.SetBodyPageUsage("A1_2",true );
FusionPro.Composition.SetBodyPageUsage("A1_3",true );
FusionPro.Composition.SetBodyPageUsage("A1_4",true );
FusionPro.Composition.SetBodyPageUsage("A1_5",true );
}
if (Field("PageCount") == "48")
{
FusionPro.Composition.SetBodyPageUsage("A1_1",true );
FusionPro.Composition.SetBodyPageUsage("A1_2",true );
FusionPro.Composition.SetBodyPageUsage("A1_3",true );
FusionPro.Composition.SetBodyPageUsage("A1_4",true );
FusionPro.Composition.SetBodyPageUsage("A1_5",true );
FusionPro.Composition.SetBodyPageUsage("A1_6",true );
}
}

I essentially have two fields that drive my page count: "Style" (could be one of three options, the code above is for the first option only), and "PageCount" (could be one of 6 options, "8", "16", "24", etc). My goal is to have the double condition activate pages 1-6 on demand, but I get that error message whenever I try to compose, and all pages come out in my composition. Any suggestions..?

Thanks!
Reply With Quote
  #2  
Old October 23rd, 2012, 06:30 PM
kc42 kc42 is offline
Forum n00b
 
Join Date: Jan 2010
Location: San Diego
Posts: 1
Default Re: Problem activating pages with SetBodyPageUsage

Try putting this code in the OnRecordStart call back rule.
Reply With Quote
  #3  
Old October 24th, 2012, 08:34 AM
jwhittaker jwhittaker is offline
Senior Contributor
 
Join Date: Feb 2009
Location: San Diego
Posts: 162
Default Re: Problem activating pages with SetBodyPageUsage

You have all your pages marked as "unused" in the Manage Page / Page Usage correct?

I use this all the time but use a "OnRecordStart" and not a "OnJobStart"
__________________
FusionPro VDP Creator 10.0.26 | MacOS 10.13.4 | Acrobat DC
Reply With Quote
  #4  
Old October 24th, 2012, 09:30 AM
esmith's Avatar
esmith esmith is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Charlotte, NC
Posts: 869
Default Re: Problem activating pages with SetBodyPageUsage

I think jwhittaker gave you the answer -- your rule needs to be in the OnRecordStart rule instead of the OnJobStart rule and all your pages should be set to unused in the Manage Pages dialog. This is because the active pages will (presumably) be different for each record based on its style and page count values.

You might also consider simplifying your callback rule as follows:
Code:
var style = Field("Style");
var activePages = parseInt(Field("PageCount"),10)/8;
for (var i=1; i<activePages+1; i++) {
   var thisPage = style + "_" + i;
   FusionPro.Composition.SetBodyPageUsage(thisPage, true);
}
__________________
Eric Smith
Content Developer
Classic
FP 9.3.6, MAC OSX 10.9.4, Acrobat 11.0.09
Reply With Quote
  #5  
Old October 24th, 2012, 11:03 AM
juliazo juliazo is offline
Junior Community Member
 
Join Date: Jun 2012
Posts: 22
Default Re: Problem activating pages with SetBodyPageUsage

Aha, it works! Thank you all!

It was a combination of all the suggestions, actually: OnRecordStart instead of OnJobStart; set all pages to unused (only had some of them set as such); and add "else if"s to my existing rule (did not try your shortened version, esmith, but thanks anyway for chipping in!)
Reply With Quote
  #6  
Old October 24th, 2012, 11:18 AM
ThomasLewis's Avatar
ThomasLewis ThomasLewis is offline
Senior Contributor
 
Join Date: Feb 2011
Posts: 215
Default Re: Problem activating pages with SetBodyPageUsage

I would go with the loop Eric wrote personally, but you could also just successively add the pages as it checks the page count like this:

Quote:
if (Field("Style") == "A1")
{
var pgct = parseInt(Field("PageCount"));
if (pgct >= 8) FusionPro.Composition.SetBodyPageUsage("A1_1",true );
if (pgct >= 16) FusionPro.Composition.SetBodyPageUsage("A1_2",true );
if (pgct >= 24) FusionPro.Composition.SetBodyPageUsage("A1_3",true );
if (pgct >= 32) FusionPro.Composition.SetBodyPageUsage("A1_4",true );
if (pgct >= 40) FusionPro.Composition.SetBodyPageUsage("A1_5",true );
if (pgct >= 48) FusionPro.Composition.SetBodyPageUsage("A1_6",true );
}

Last edited by ThomasLewis; October 24th, 2012 at 11:20 AM..
Reply With Quote
  #7  
Old October 24th, 2012, 01:09 PM
juliazo juliazo is offline
Junior Community Member
 
Join Date: Jun 2012
Posts: 22
Default Re: Problem activating pages with SetBodyPageUsage

True, I've taken the longest road on this, it seems

Thanks for the input!!
Reply With Quote
Reply

Tags
callback, error, rule, setbodypageusage

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 10:12 PM.


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