ryanceot Posted February 24, 2022 Share Posted February 24, 2022 I am trying to activate unused pages using if ((Field("DATE01") != "")) { FusionPro.Composition.SetBodyPageUsage("Itinerary",true); } The presence of data in DATE01 is what I'd like to trigger the page to appear. What the data is irrelevant. I've tried using "!=" and "==". Any help is appreciated. Thanks! -Ryan Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted February 25, 2022 Share Posted February 25, 2022 That seems right, though I can't say for sure without the job. Is it not working for you? Are there any messages in the log file? Is the page marked as Unused initially? It won't matter if you do this instead: FusionPro.Composition.SetBodyPageUsage("Itinerary", Field("DATE01") != ""); The only other thing I can think of is that your data field might not actually be empty, if there are spaces. So you could try: FusionPro.Composition.SetBodyPageUsage("Itinerary", Trim(Field("DATE01")) != ""); Quote Link to comment Share on other sites More sharing options...
ryanceot Posted February 25, 2022 Author Share Posted February 25, 2022 (edited) Here's the .zip file. I've deleted some assets to make the .zip smaller and deleted other sensitive info. Some art or merge fields might not appear correctly. Thank you for taking a look at it. -RyanRC22.zip Edited February 25, 2022 by ryanceot Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted February 25, 2022 Share Posted February 25, 2022 Thanks for posting the job. The line of code you posted is fine. But this error message appears in the log file: uncaught exception: Error: In SetBodyPageUsage(), no page named "TH" The problem is further up in the OnRecordStart rule: if (((((Field("PCOMP") == "6") || (Field("PCOMP") == "2")) || (Field("PCOMP") == "D")) || (Field("PCOMP") == "4")) && (Field("PINSC") == "Y")) { FusionPro.Composition.SetBodyPageUsage("TM",true); } if ((Field("PINSC") == "Y") && (Field("PCOMP") == "Y")) { FusionPro.Composition.SetBodyPageUsage("TM",true); } [color="DarkRed"]if ((Field("HOST") == "Y")) { FusionPro.Composition.SetBodyPageUsage("TH",true); }[/color] if ((Field("SCC") == "1")) { FusionPro.Composition.SetBodyPageUsage("BC",true); } if ((Field("DATE01") != "")) { FusionPro.Composition.SetBodyPageUsage("Itinerary",true); Print("Itinerary page activated."); } The rule throws an exception when the call to set the usage of a non-existent page "TH" fails, and therefore the rest of the rule does not get run. This is why I asked: Are there any messages in the log file? Almost always, there's something in there that's at least a hint as to what the problem is. It's also why it's often difficult, if not impossible, to figure out what the problem is from just a snippet of code. The short answer to how to fix this is: remove the code that's calling out a page that doesn't exist (or add a page with that name). The longer answer is, if you might have callouts for pages that don't exist, then you can put each call into its own try/catch block, so that, even if an exception is thrown, the rest of the rule still runs, like so: if (((((Field("PCOMP") == "6") || (Field("PCOMP") == "2")) || (Field("PCOMP") == "D")) || (Field("PCOMP") == "4")) && (Field("PINSC") == "Y")) { try { FusionPro.Composition.SetBodyPageUsage("TM",true); } catch (ex) { Print(ex); } } if ((Field("PINSC") == "Y") && (Field("PCOMP") == "Y")) { try { FusionPro.Composition.SetBodyPageUsage("TM",true); } catch (ex) { Print(ex); } } if ((Field("HOST") == "Y")) { try { FusionPro.Composition.SetBodyPageUsage("TH",true); } catch (ex) { Print(ex); } } if ((Field("SCC") == "1")) { try { FusionPro.Composition.SetBodyPageUsage("BC",true); } catch (ex) { Print(ex); } } if ((Field("DATE01") != "")) { try { FusionPro.Composition.SetBodyPageUsage("Itinerary",true); } catch (ex) { Print(ex); } } I also see quite a bit of repetition in your job, with all of those rules like Format Date Itin 01, Format Date Itin 02, Format Date Itin 03, etc. A lot of that could be greatly reduced with a rule with a for loop starting with something like "for (var i = 1; i <= 20; i++)", but I'll leave that for another thread. Quote Link to comment Share on other sites More sharing options...
ryanceot Posted April 5, 2022 Author Share Posted April 5, 2022 Thank you Dan! Just realized I never posted a thank you. With all the work done on the dates, I think I'll leave as is for now, but I'm interested to know the shortcut. Quote Link to comment Share on other sites More sharing options...
Sophia78 Posted March 18, 2023 Share Posted March 18, 2023 Hello Guys, "OnRecordStart" refers to the moment when a recording starts, and in the context of data, it can refer to the beginning of a data collection or recording process. The presence of data generally refers to the fact that some data exists, without specifying the type or content of that data. For example, if a company says "we have data on customer preferences", that statement indicates that there is some information about customer preferences available, but it doesn't specify what that information is. Quote Link to comment Share on other sites More sharing options...
Douglas Cogan Posted March 19, 2023 Share Posted March 19, 2023 Hello Sophia, OnRecordStart in regards to FusionPro is a rule that is executed at the beginning of each new record. It is a rule that is called when certain events happen, like when a all the pages are complete after being inserted. What you wrote above may be correct in other contexts, but in regards to FusionPro it is a rule that is executed after each new record of data has been read from the data source and before any other processing is done. FusionPro doesn't do any recording of any data. I hope that clears things up a bit. 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.