- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2015 01:00 PM
I am making a scoped application in Fuji. I having a problem when I try to call a Script Include from a Business rule. I have confirmed that all of the artifacts such as the script include and business rule are all residing in the same application scope.
I should be able to call the script include as such:
var x = new MyScript();
x.myFunction();
The business rule:
function onBefore(current, previous){
var lu = new LoanerResUtils();
lu.isAvailable();
}
This is not working and I see the undefined error in the log.
The script include name is LoanerResUtils.
org.mozilla.javascript.EcmaError: The undefined value has no properties.
Caused by error in Business Rule: 'Loaner Res Item Availability' at line 20
==> 20: var lu = new LoanerResUtils();
21: lu.isAvailable();
I tried using the fully-qualified scope name but that did not work either.
org.mozilla.javascript.EcmaError: "x_myscp_loaner_res_LoanerResUtils" is not defined.
Caused by error in Business Rule: 'Loaner Res Item Availability' at line 20
==> 20: var lu = new x_myscp_loaner_res_LoanerResUtils();
21: lu.isAvailable();
This exact syntax has worked for me in Eureka so I am not sure what could be the issue here.
Let me know if anyone has any possible solutions!
Here is the script include.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2015 02:43 PM
Hi Kathryn,
Do you have an initialize method in your Script Include? You need one for the Prototype class-extension.
var LoanerResUtils = Class.create();
LoanerResUtils.prototype = {
//THIS IS REQUIRED
initialize: function() {
},
//ALL YOUR METHODS DEFINED LIKE THIS
isAvailable : function() {
//whatever logic
},
//THIS IS ALSO REQUIRED
type: 'LoanerResUtils'
};
If you go the Class extension route (the default for Script Includes) you need to have an initialize method (even if it's empty) and a type declaration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2015 03:12 PM
Thank you again Cory you are an excellent resource!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-16-2017 12:10 PM
So what was the problem?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2017 08:00 PM
Hi Ramon,
Sorry, I don't remember. Maybe Kathryn still has the Update Versions for that include and can tell you.
It was long time ago, so I wouldn't count on it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2017 04:07 AM
In my case it was a problem with the function's scope.
(functionName() couldn't be called from my business rule.)
I used the full path of the script include function in my business rule (x_snc_scope).functionName() and it called it.
What's weird is that I'm doing everything in studio on the same custom app, and on the same scope.
Oh well, thank you!
#Instanbul #SNOW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2017 06:40 AM
We ended up rebuilding in a standard non-scoped application. We were running into too many issues with scoped apps. Next time if we decide to switch back to building scoped apps I will look into your solution for this particular issue. Thanks for letting us know!
