Scripts fails when triggered with error message stating "Unable to load script "
Hi,
I have already talked about this issue in another thread but since then I have made some tests and I think it will be more clearer to create a new post for it.
I have written a few scripts to customize some attributes. Most of them are calculated values but I also have some validators and 2 value sets scripts.
I will focus only on 2 Value Providers and on my 2 Value Sets scripts here.
To give you an overview of the way I designed my "script architecture", I made the following schematic :
The boxes in white represent the custom attributes I have defined.
Their type is "small string".
To automatize the filling of the attributes "Location" and "Cross Asset" I decided then to write some scripts (grey boxes) that can provide a value according to the selected Requestor.
I first wanted to write an xml file with all those info but I am unable to write directly on the server so I wrote a value set script which returns a 3-dimensional array containing the needed info for each requestor.
This class is then "required" in all scripts :
- ValueSet_FilterRequestor.js (filtered value set script) is the script linked to the requestor attribute. This allows to filter the list according to the value typed in the value set picker filter (editor).
- ValueProvider_Req2Loc.js (Calculated value) will retrieve the selected name in the value set picker and make it match with the associated location.
- ValueProvider_Req2CrossAsst.js (Calculated value) will retrieve the selected name in the value set picker and make it match with the associated cross asset.
Then the hard things begin :
When the three scripts are linked to the attributes in the Eclipse client with no dependencies (Requestor for both Location and Cross Asset), everything works properly (no error) but when I add the dependencies (to trigger the scripts when attribute Requestor changes), I obtain the following error either in Firefox or in IE (it works fine in the Eclipse client):
I checked the logs with Firebug and (strange thing) it seems that my script is not on the server (or not where it is supposed to be).
Has anyone ever faced a similar issue and managed to solve it ? Or should I be totally desperate ? :)
Thank for your help
5 answers
Actually the three scripts ValueSet_FilterRequestor.js, ValueProvider_Req2Loc.js and ValueProvider_Req2CrossAsst.js require the class ValueSetProvider_Requestors.
Below is an extract of my code :
ValueProvider_Req2Loc.js (ValueProvider_Req2CrossAsst.js is the same script except that I return requestors[j][2])
ValueSet_FilterRequestor.js
ValueSetProvider_Requestors
Comments
Yes at first I thought it might come from the position of "dojo.provide" this is why I tried to put it in several locations. However this has not worked as the error is triggered anyway.
I will try the "debug" mode next week as I am off tomorrow and I will keep you posted. Hope that will help.
I checked with the debug mode set to true but it is not as verbose as expected.
As an example please find below a screenshot of what I obtain as soon as I open a webpage
Apparently the following function seems to fail :
// FIXME: probably need to add logging to this method
dojo._loadUriAndCheck = function(/*String*/uri, /*String*/moduleName, /*Function?*/cb){
// summary: calls loadUri then findModule and returns true if both succeed
var ok = false;
try{
ok = d._loadUri(uri, cb);
}
catch(e){
console.error("failed loading " + uri + " with error: " + e);
}
return !!(ok && d._loadedModules[moduleName]); // Boolean
}
but the failing file is ValueSetProvider/Requestors.js... is it possible you attached an earlier version of the Requestors.js file and it is still attached to the project area?
I already tried to delete all the links and reload all the scripts unsuccessfully.
However I agree with you on one point : the path we see in Firebug is wrong and is not in line with what I can see in both the "Links" tab and the "Attribute Customization" section :
This really is a brain-teaser...
Comments
Curtis d'Entremont
FORUM MODERATOR / JAZZ DEVELOPER Dec 05 '12, 11:31 a.m.