Use global variable for url parameter in widget config

691
3
12-06-2018 07:56 AM
AndrewHayden1
Occasional Contributor

I'm not sure I'm best articulating the question or the path I'm trying to go down here but I'm wondering about having a configurable value that can be concatenated to a url parameter in a widget config.  I have a case where a portion of a url changes based on if the application is a development or production version.  As opposed to having a dev and prod config for each widget that has different dev and prod urls, I'd like to just have a configurable value I can set that will be concatenated to the rest of whatever url value is in the widget config.  I was thinking, I could set a global variable when the application loads maybe something like var PrdOrDev = 'PartOfUrlThatMakesItPrdorDev' and then in my widget config change the url parameter to "${MyDeploymentVersion}/moreurl/arcgis/rest/blah/blh/blah" and then modify processUrlInWidgetConfig in utils.js to handle url.startWith('${MyDeploymentVersion}) by replacing it with window.PrdOrDev.  For anyone that's followed me this far, is this a proper track or is it completely off the rails?

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus

Andrew,

   That is a viable path. The processUrlInWidgetConfig method is not used be default in the widget though so you would have to modify each widget to use this method be handling a url.

AndrewHayden1
Occasional Contributor

Thanks Robert.  I hadn't thought of that.  In your opinion, is maintaining DEV/PROD config files for each widget the more prudent approach?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

absolutely