Enabling a Custom Geoprocessing Widget in WAB Fails

247
7
09-05-2019 09:59 AM
Highlighted
New Contributor II
Hi all:
I am getting the following error when attempting to publish a widget to WAB in our Enterprise Portal. The file is definitely there so I am hoping this is a simple issue, but am utterly stuck. This was replicated using the stock geoprocessing widget as well by publishing that to the same server.
GET https://maps.gpinet.com/Test/widgets/Geoprocessing/nls/strings net::ERR_ABORTED 404 (Not Found)
init.js:37 Error: scriptError at c (init.js:11) at HTMLScriptElement.<anonymous> (init.js:35)
init.js:37 src: dojoLoader
init.js:37 info:
  1. (2) ["https://maps.gpinet.com/Test/widgets/Geoprocessing/nls/strings", Event]
    1. 0: "https://maps.gpinet.com/Test/widgets/Geoprocessing/nls/strings"
    2. 1: Event {isTrusted: true, type: "error", target: script, currentTarget: null, eventPhase: 0, …}
    3. length: 2
    4. __proto__: Array(0)
7 Replies
Highlighted
Occasional Contributor

The problem here is that when you publish a widget into Portal its hosted outside the WAB and you run into issues with paths. Widgets/MyWidget will no longer work. I'm not 100% sure on i18n, it always seems to work differently with paths to other dojo require items. Anyway I ran into the same issue with the AddData widget so here is what I think. With the geoprocessing widget I see:

RecordSetEditorChooser.js: 26

'dojo/i18n!../nls/strings',

Here there is a path and it is failing to find it, the error message is misleading I think its actually looking for it in the WAB. There should be a way to make it work as a relative path but I'm not sure what it is. I ended up just requiring the js file relatively (so no i18n):

'./nls/strings',

then using the .root property:

RecordSetEditorChooser.js: 38

lang.mixin(this.nls, gpNls.root);

This means your localisation won't work, but at least the widget may work...

With the add data widget there were lots of data-dojo-type within the templates. Remember "widgets" no longer works as a path, this is looking in the widgets folder of the WAB, not local to your widget. To fix this I ended up removing the data-dojo-type and creating the widgets within widget.js. Hoepfully you won't have to do this and it will be the simple one line fix above (because this is a nightmare)

data-dojo-type="widgets/AddData/search/ScopeOptions"

The main point is that you have to get into the mindset that everything must work relatively if you are going to host the widget for portal

Reply
0 Kudos
Highlighted
New Contributor II

Hi, I have the exact same issue with the AddData widget. Could you possibly share your code if you managed to get it working?

Highlighted
Occasional Contributor

Completely hacked together, but it it should work at least

Dropbox - AddDataPortal.zip - Simplify your life 

Highlighted
New Contributor II

Thank you very much! I am unfortunatley not able to download the zip-file from that link. Could you try share the file again? Otherwise you could send it to my email perhaps

Reply
0 Kudos
Highlighted
Occasional Contributor

Sorry try again. If this doesn't work drop me a PM on linked in (I don't think you can PM on geonet? 

Dropbox - AddDataPortal.zip - Simplify your life 

https://www.linkedin.com/in/davidjwilton/ 

Highlighted
New Contributor II

I managed to download now! Thank you for helping out!

Reply
0 Kudos
Highlighted
Occasional Contributor

Øystein, I realised there was an issue with the NLS if you were using the "add from file" option. updated here

Dropbox - AddDataPortal.zip - Simplify your life 

Reply
0 Kudos