How to use url parameters in Query widget

2677
8
Jump to solution
12-03-2019 11:57 AM
FranklinAlexander
Occasional Contributor III

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

https://ocean.floridamarine.org/InDevelopment/GA_WebProjects/WMA_Entrances/WMA_EntranceFinderWAB2.13_sandbox1/?query=WMA%20Entrances%20Florida,NAME_ENT,Andrews%20WMA

This url seems to work, no error.

https://ocean.floridamarine.org/InDevelopment/GA_WebProjects/WMA_Entrances/WMA_EntranceFinderWAB2.13_sandbox1/?WMA%20Entrances%20Florida,NAME_ENT,Andrews%20WMA

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! 

Use URL parameters—Web AppBuilder for ArcGIS | Documentation 

URL query parameters in Web AppBuilder — CommunityHub 

 

Thanks for any clarifications

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Querying layers loaded by the local layer widget are not supported for URL queries. The eSearch allows for searching layers that are not part of the web map.

View solution in original post

0 Kudos
8 Replies
RobertScheitlin__GISP
MVP Emeritus

Franklin,

   Everything is pretty well covered in the help page. Use URL parameters—Web AppBuilder for ArcGIS | Documentation 

Layre ID:

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

0 Kudos
FranklinAlexander
Occasional Contributor III

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.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Franklin,

   So if you webmap only contains a basemap then how are the two operational layers added to your app?

0 Kudos
FranklinAlexander
Occasional Contributor III

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.  

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Querying layers loaded by the local layer widget are not supported for URL queries. The eSearch allows for searching layers that are not part of the web map.

0 Kudos
FranklinAlexander
Occasional Contributor III

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. 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Yes you can if you do the coding yourself.

FranklinAlexander
Occasional Contributor III

Thanks for the clarification. At least I have a direction! 

0 Kudos