Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old January 18th, 2018, 10:56 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,671
Default Re: Determine if a text frame exists

Quote:
Originally Posted by ThomasLewis View Post
Attached is my template with the external JS file. When you open OnRecordStart and click validate, it returns "null". If I paste the code from the JS file directly into OnRecordStart, it returns the error as you would expect.

I get where you are coming from trying to keep things organized. Hopefully this will make more sense with the attached sample.
Thanks. As I expected, you're not actually returning anything in your rule. There's no "return" statement in there.

As I said before, and as Step demonstrates, the proper way to use an external JS file (which, again, is a topic pretty far afield from the original question in this thread) is to put a function in there, then call that function after loading the file.

Merely calling the Load function doesn't execute any code in the external JS file; though it will cause any objects and functions declared in the JS file to be included in the active JavaScript context (which allows you to use/call them after calling Load).

The reason that calling Load from your JS file causes a box saying that you're returning null to pop up is because you're trying to call a function outside the context of another function or rule, on the last line, where you're calling the TryToFindTextFrame function. (Which I never suggested to do, by the way; I only said you should declare it in the JS file, not call it in the JS file.) But as the message box notes, the return value from a callback rule has no effect on the composition anyway.

Step's solution is great, but I would put the Load call in the JavaScript Globals, instead of in OnRecordStart. For one thing, you don't need to load it over and over again on every record. You could put it in OnJobStart instead, but then it won't necessarily get loaded up when you validate another rule. The purpose of the JavaScript Globals is to declare objects and functions, which is exactly what you're doing by loading the JS file.

Anyway, having said that, I'm still not sure that you're gaining that much by doing all of this. If your end user template designer tries to call FindTextFrame on a frame that doesn't exist, that will already raise an exception and put up the box with the error icon when they validate or try to save the rule. All this work does is simply put up a slightly different error message saying basically the same thing.

But maybe I'm missing something else that's not shown in the very minimal example job you posted. If I knew more about the real job where you "require the operator to modify the text frames on a per job basis", I might be able to offer more specific suggestions, or maybe even another approach.
__________________
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
  #12  
Old January 18th, 2018, 12:09 PM
ThomasLewis's Avatar
ThomasLewis ThomasLewis is offline
Senior Contributor
 
Join Date: Feb 2011
Posts: 233
Default Re: Determine if a text frame exists

With the previous way I was trying to do this, where the only javascript in the entire template was the Load function, no errors appear at all at save and validation only would result in a "null" message. This is why I was trying to change that message, I was just unaware that could not be done fully in the external file when everything else in there was working just fine.

Whether it is supposed to execute or not, everything in the actual production JS file I was loading in did preview and render in the final output. Now that I am calling it as a function, I get the proper errors that you would expect. It all make's a lot more sense now thanks to both of your help.
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 11:43 PM.


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