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
Hi, I have the exact same issue with the AddData widget. Could you possibly share your code if you managed to get it working?
Completely hacked together, but it it should work at least
Dropbox - AddDataPortal.zip - Simplify your life
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
Thank you very much!
It helped me a lot.
Hi @DavidWilton thank you so much for sharing your widget code. I have the exactly the same issue and have been stuck with this for days...
Could you clarify what you did to get it to work was ONLY replacing the original "dojo/i18n!../nls/strings" to ".nls/strings" and creating local nls folders with those translation files?
Do I also need to make these two changes? If necessary, where do I look for these two places to change?
- the RecordSetEditorChooser.js: 38 change "lang.mixin(this.nls, gpNls.root)"
- data-dojo-type="widgets/AddData/search/ScopeOptions"
Many thanks!
Wen
I reread your post and realized that the "RecordSetEditorChooser.js" was referring to the Geoprocessing widget, so that's why I couldn't find it in the AddData widget....
and the data-dojo-type="widgets/AddData/search/ScopeOptions" is something hopefully we don't need to modify, right?
Thank you!
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.