Jump to content

OnRecordStart Presence of Data vs. Specific Data


Recommended Posts

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

Link to comment
Share on other sites

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")) != "");

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 1 month later...
  • 11 months later...

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.

Link to comment
Share on other sites

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.

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...