How to create a custom config?

1995
12
Jump to solution
09-17-2018 05:49 PM
GregRieck
Occasional Contributor III

Hello,

I have several widgets the reference rest end point URL's. I would like to be able to use a config file in the root folder of the WAB site to store the path to these URL's. I have found the config.json file in the root directory. Within the config.json file I have changed the "config": path from "configs/..." path to the root, ie "config": "mycustom.json".

mycustom.json has a reference to a rest end point

{

"myUrl": "'//myportal.com/server/rest/services/SiteName/FeatureServer/SomeNumber'",

additional urls.....

}

Now how do I access mycustom.json within the individual widget.js files?

var myurl = ??. mycustom.json.???myUrl????

If I am off base with this approach please let me know. I didn't want to have a separate config file for each widget as each widget would be using the same URL's in the config file.

Thank You,

Greg

Tags (1)
0 Kudos
12 Replies
GregRieck
Occasional Contributor III

Robert,

this.config.oneUrl is not defined in postCreate but it is available and accessible in the startup function. Thank you for the help on this.

Greg 

0 Kudos
GregRieck
Occasional Contributor III

Robert,

I found another location where it would be helpful to be able to use the name value pair from my config file. It's in a FeatureAction in a couple of my widgets. Do you know how I can get access to "this.config" within a FeatureAction?

Greg

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Greg,

    A FeatureAction does not have any tie back to a widget so there is no access to a widget config by default. The only way to get this would be to find the widget using WidgetManager getWidgetsByName function and then you could get the widgets config.

0 Kudos