Jump to content

Issues with OnRecordStart


EX_BCBS

Recommended Posts

I'm trying to run 2 functions in OnRecordStart and not having any luck with either one. I'm trying to set the which page needs to run and then set how many times to repeat that record.

 

In my data I have a field that either gives me a file name, or just calls Banner. When it calls for banner, I need to to only pull the first page and just give me 1 count of that record. If it gives me a file name, I need to pull the second page and repeat that record "n" times based on another field in my data. My rule consists of IF statements to call the correct function. Any help would be appreciated.

 

//Setting PDF page

 

if (Field("PDF Name") == "Banner")

FusionPro.Composition.SetBodyPageUsage("Banner", true)

else if (Field("PDF Name") != "Banner")

FusionPro.Composition.SetBodyPageUsage("Shell", true)

 

//Setting number of repeat records

 

if (Field("PDF Name") == "Banner")

FusionPro.Composition.repeatRecordCount == "1"

else if (Field("PDF Name") != "Banner")

FusionPro.Composition.repeatRecordCount == Field("MB_Quant")

Link to comment
Share on other sites

What exactly are the results, and how are they different than what you're expecting?

 

A little bit of debugging might help to shed light on what's happening. Try this:

Print('Field("PDF Name") is: ' + Field("PDF Name"));
if (Field("PDF Name") == "Banner")
{
 Print("Activating page Banner");
 FusionPro.Composition.SetBodyPageUsage("Banner", true)
}
else
{
 Print("Activating page Shell, repeating " + Field("MB_Quant") + " times");
 FusionPro.Composition.SetBodyPageUsage("Shell", true)
 FusionPro.Composition.repeatRecordCount == Int(Field("MB_Quant"));
}

Compose and look in the log (.msg) file for the Print messages.

Link to comment
Share on other sites

Dan,

Thanks for the reply. I've made a little progress this sense this morning. I've got the repeat record working the way I would like. Now it's just a case of getting the page usage correct. Here is the code I've got right now for setting page usage.

 

if (Field("PDF Name") =="BANNER")

FusionPro.Composition.SetBodyPageUsage = ("Banner", true)

else

FusionPro.Composition.SetBodyPageUsage = ("Shell", true)

 

I've tried enabling and disabling page usage within Manage Pages and I can't seem to get right pages to activate. I tried your code to print to the message file, but it get an error that FusionPro.Composition.SetBodyPageUsage is not a function. Thoughts?

 

Kevin

Link to comment
Share on other sites

Dan,

Thanks for the reply. I've made a little progress this sense this morning. I've got the repeat record working the way I would like. Now it's just a case of getting the page usage correct. Here is the code I've got right now for setting page usage.

 

if (Field("PDF Name") =="BANNER")

FusionPro.Composition.SetBodyPageUsage = ("Banner", true)

else

FusionPro.Composition.SetBodyPageUsage = ("Shell", true)

 

I've tried enabling and disabling page usage within Manage Pages and I can't seem to get right pages to activate. I tried your code to print to the message file, but it get an error that FusionPro.Composition.SetBodyPageUsage is not a function. Thoughts?

 

Kevin

Actually, the issue is that FusionPro.Composition.SetBodyPageUsage IS a function; but you're not calling it like one. Somewhere along the line between your original post and your latest one, you seem to have erroneously added an equal sign (in Red above) to the lines with that function. With those equal signs, what you're actually doing is assigning the FusionPro.Composition.SetBodyPageUsage property to something else instead of calling the function associated with it; thus the error message.

 

To fix this, you just need to get rid of those extraneous equal signs. So, change from this:

if  (Field("PDF Name") =="BANNER")
 FusionPro.Composition.SetBodyPageUsage [color=Red]=[/color] ("Banner", true)
else
 FusionPro.Composition.SetBodyPageUsage [color=Red]=[/color] ("Shell", true) 

To this:

if  (Field("PDF Name") =="BANNER")
 FusionPro.Composition.SetBodyPageUsage("Banner", true);
else
 FusionPro.Composition.SetBodyPageUsage("Shell", true);

Also, you can put your code in forum posts into Code blocks like in my post here by clicking "Go Advanced" under the Quick Reply box, then selecting the code and clicking the "#" button.

Link to comment
Share on other sites

On a good note, I was able to get the rule to work as I needed. For some reason the first time the rule is written it was giving me a validation error. I ended trying to rewrite the file anyway I could to not get the error. After seeing your examples I went back to what I had written even though it still gave me an error. I Ok'd through the error, saved and composed and everthing turned out as it should. When I go into the rule now, I don't get the validation error.

 

Thank you for the help.....if not for the clarification I'd still be stuck trying to figure out why I was getting a validation error.

 

 

Kevin

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...