merski007 Posted December 21, 2017 Share Posted December 21, 2017 (edited) Hello, I'm using the Load() function in my OnJobStart to load an external JS file. I'm calling a function from that file in my OnRecordStart, and it works, but when I save/validate the OnRecordStart rule I get the attached error message. Does anyone know how to get rid of this error message? In case you can't see the image, it's a ReferenceError that states the function is not defined. Edited December 21, 2017 by merski007 Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 21, 2017 Share Posted December 21, 2017 Sorry, I can't make out anything from that screenshot. A picture is usually worth a thousand words, but in this case, copying and pasting the text of the rule would be more helpful, along with the JS file itself. Quote Link to comment Share on other sites More sharing options...
step Posted December 21, 2017 Share Posted December 21, 2017 You can add this to your OnRecordStart rule so that it will load the file when you're validating the rule. if (FusionPro.inValidation) Rule("OnJobStart"); Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted December 21, 2017 Share Posted December 21, 2017 Actually, you shouldn't need the OnJobStart rule at all, if all it's doing is loading the JS file. You can just do this at the top of the rule that's calling the function from the external JS file: if (FusionPro.inValidation || typeof [color="Green"]setOutputType[/color] == "undefined") Load([color="green"]"setOutputType.js"[/color]); Using your own function name and file name (in green above), of course. Quote Link to comment Share on other sites More sharing options...
merski007 Posted December 27, 2017 Author Share Posted December 27, 2017 Thanks Dan and Step, both worked great. Since I'm loading multiple JS files in the OnJobStart, I'm thinking it would be safer to use Step's method, since that calls the rule and all files will be loaded. We are just diving into the external JS file callout methods and so far they have been a big help. We do a ton menu products that share the same rules, so this is becoming a real lifesaver on preventing us from writing duplicate code in each template. Thanks for the helps and have a Happy New Year! 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.