Jump to content

Problem activating pages with SetBodyPageUsage


juliazo

Recommended Posts

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:

 

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!

Link to comment
Share on other sites

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:

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);
}

Link to comment
Share on other sites

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!)

Link to comment
Share on other sites

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:

 

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 );

}

Edited by ThomasLewis
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...