It's all about the answers!

Ask a question

Scripts fails when triggered with error message stating "Unable to load script "

Gilles Trautmann (3634) | asked Dec 04 '12, 3:27 a.m.


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


Curtis d'Entremont commented Dec 05 '12, 11:31 a.m.

Are there any cycles in your dependency hierarchy? I noticed the arrows are bi-direction, wasn't sure if this is accurate or not. Currently, the Web UI doesn't support circular dependencies.

5 answers

permanent link
Gilles Trautmann (3634) | answered Dec 06 '12, 3:01 a.m.
Sorry about the bad drawing (I did it quickly) but no there is no cycle in my dependency hierarchy.

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])



Curtis d'Entremont commented Dec 06 '12, 10:11 a.m.

The only thing I see out of the ordinary is that the dojo.provide sometimes comes after the dojo.requires, which is not wrong, but may be triggering a bug in the JavaScript optimization, which reads all the files and forms a dependency tree. Try moving at the top, the very first line, and see if it works.

Another thing that might help you is to turn on debug mode by adding the "?debug=true" parameter to your URL. (his comes before the hash, so e.g. /path?debug=true#...)  This turns off the JavaScript minification (compression) and doesn't combine the whole dependency hierarchy into a single JavaScript bundle. There is also another debug mode, ?debug=dojo, which just turns off the minification but still combines the bundles. These might help give you clues to the issue since debugging minified JavaScript is difficult.

permanent link
Gilles Trautmann (3634) | answered Dec 06 '12, 10:34 a.m.
Thanks for the tip.

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.

permanent link
Gilles Trautmann (3634) | answered Dec 10 '12, 9:21 a.m.
Hi again,

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;
        ok = d._loadUri(uri, cb);
        console.error("failed loading " + uri + " with error: " + e);
    return !!(ok && d._loadedModules[moduleName]); // Boolean

permanent link
Lawrence Smith (3764) | answered Dec 11 '12, 11:56 a.m.
It looks like the name of your file might be


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? 

You can check this by looking at the Links page of the Project Area. This would explain why the "wrong version" appeared to be loaded, and why there might be a syntax error in the old version which is not in your new version.

Larry Smith [IBM RTC Development]

permanent link
Gilles Trautmann (3634) | answered Dec 11 '12, 12:05 p.m.
Hi Larry,

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...

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.