Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Getting Started, Learning, Etc.

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 24th, 2022, 02:05 PM
ryanceot ryanceot is offline
Forum n00b
 
Join Date: Feb 2020
Posts: 9
Default OnRecordStart Presence of Data vs. Specific Data

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
Reply With Quote
  #2  
Old February 24th, 2022, 06:12 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,693
Default Re: OnRecordStart Presence of Data vs. Specific Data

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:
Code:
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:
Code:
FusionPro.Composition.SetBodyPageUsage("Itinerary", Trim(Field("DATE01")) != "");
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old February 25th, 2022, 09:50 AM
ryanceot ryanceot is offline
Forum n00b
 
Join Date: Feb 2020
Posts: 9
Default Re: OnRecordStart Presence of Data vs. Specific Data

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.

-Ryan
Attached Files
File Type: zip RC22.zip (20.57 MB, 5 views)

Last edited by ryanceot; February 25th, 2022 at 10:02 AM..
Reply With Quote
  #4  
Old February 25th, 2022, 02:49 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,693
Default Re: OnRecordStart Presence of Data vs. Specific Data

Thanks for posting the job.

The line of code you posted is fine. But this error message appears in the log file:
Quote:
uncaught exception: Error: In SetBodyPageUsage(), no page named "TH"
The problem is further up in the OnRecordStart rule:
Code:
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);
}

if ((Field("HOST") == "Y"))
{
FusionPro.Composition.SetBodyPageUsage("TH",true);
}

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:
Quote:
Originally Posted by Dan Korn View Post
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:
Code:
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.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #5  
Old April 5th, 2022, 03:33 PM
ryanceot ryanceot is offline
Forum n00b
 
Join Date: Feb 2020
Posts: 9
Default Re: OnRecordStart Presence of Data vs. Specific Data

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.
Reply With Quote
Reply

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 03:08 PM.


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