I am trying to use URL parameters to execute a search with the Query widget, but am having trouble getting the widget to see the url correctly. when I try and use the built in 'query' parameter, no matter what id I use I get an 'invalid id' message in the console. I am very unclear as to what id it is asking for since the layer id I am trying to query on isn't some long integer, at least not that I can find. The layer id in the config file is the 'name' of the layer, which doesn't work, and if I try using the id from the REST service json page for the layer, that doesn't work either. Do I have to generate the id somehow?
This url throws invalid id error
This url seems to work, no error.
Aside from the id question, is there an advantage to using the 'query' parameter? Are there any limitations in not using it? I am still able to extract the parameters in the widget.js file using both jimuUtils.urlToObject() method and getUrlParams() method.
I have already looked at the esri docs, but am still confused!
Thanks for any clarifications
Solved! Go to Solution.
Everything is pretty well covered in the help page. Use URL parameters—Web AppBuilder for ArcGIS | Documentation
Since the layer name can be changed, it is strongly recommended that you use the layer ID in the query. You can retrieve the layer ID from the web map ID, as shown here: http://<your portal url>/sharing/rest/content/items/32a83775654249dcae6b8f2eff5d4072/data/?f=pjson
I did try to do that Robert, but all I get is the World Topo basemap. I took the portalUrl and the itemId from the config.json file, substituted it into the url and it shows the basemap, but no operational layers. I should be seeing two of them. I assumed that this is because the layers are loaded separately from the basemap, so I don't really have a web map like you would if you created a WAB online app. Still don't know what I am missing.
I have two rest service feature layers added to the map using the Local Layer widget.
1. Wildlife Management Area Entrances Florida (this is the one I want to query)
2. Wildlife Management Areas
Both show up in the map and I am able to query the 1st one just fine using the query widget. I need to be able to run the query from the url as well. for instance if someone accesses the app from a particular WMA page, it will query that WMA and zoom to it on the map.
If I am able to query the WMA Entrance layer, can't I just pull the parameters from the html and plug them in? I can get them using getUrlParams() function as long as I don't use the 'query' parameter. Theoretically, I should be able to plug them in to the query filter and run the query. I know using the eSearch would be a lot easier, but I need to be able to filter each subsequent dropdown menu by the previous expression and I can't find a way to do that with the eSearch widget. That's kind of important since there are over 100 WMAs.