Select to view content in your preferred language

Search Widget URL Parameter Not Working with Zoom To Action

817
6
Jump to solution
08-06-2024 11:20 AM
Labels (1)
Paul_M
by
New Contributor

I'm trying to allow links to an Experience Builder app from outside sources to incorporate a URL parameter that automatically opens the app and zooms to text entered in the Search widget box. In my app, searching via the Search widget zooms to the first location match and updates the URL accordingly. However, when entered as a URL parameter to visit or update the app page, it fills out the search box and highlights the first match, but does not zoom to the location. Why doesn't it zoom to the location when used as a URL parameter? Does anyone know of a workaround?

0 Kudos
1 Solution

Accepted Solutions
Paul_M
by
New Contributor

After some more troubleshooting, it seems that the zoom action does not work when the search widget is in the header. I'm guessing this is a bug. After moving it out of the header and onto the map, it is working. 

View solution in original post

0 Kudos
6 Replies
Paul_M
by
New Contributor

After some more troubleshooting, it seems that the zoom action does not work when the search widget is in the header. I'm guessing this is a bug. After moving it out of the header and onto the map, it is working. 

0 Kudos
FredericPoliart_EsriAU
Frequent Contributor

I am having issues crafting a URL to invoke/assemble a where query to a Search Widget in Experience Builder.

1. Extract the ExB data using https://ago-assistant.esri.com/ 
2. open in Notepad
3. Observe the JSON :  teh search widget is widget_30
 "widget_30": { "uri": "widgets/common/search/",
4. within the search widget JSON . I can see the various data sources of that search widget (that is the multiple datasources being used and configured ), 
It shows:

 "useDataSources": [
                {
                    "dataSourceId": "f50d125139c545daa1d1120cbe3ff54d-191076be876-layer-120-191076bf00d-layer-131",
                    "mainDataSourceId": "f50d125139c545daa1d1120cbe3ff54d-191076be876-layer-120-191076bf00d-layer-131",
                    "rootDataSourceId": "f50d125139c545daa1d1120cbe3ff54d",
                    "fields": [
                        "Property_Address",
                        "Property_Number",
                        "Assessment_Number"
                    ]
                },

 

For that queried layer -131<?> , there is an attribute called "Property_Number" and I know there is a PropID 16600080

So my URL looks something like this: 
https://experience.arcgis.com/experience/{PortalItemID}/#data_s=where:widget_30-dataSource_1-191076bf00d-layer-131:Property_Number=16600080


This doesn't seem to work. 

Q# Has anyone got a logical method to assemble a URL that would open Experience Builder and automatically inject a search in the search widget

Q# Is there a simpler way to do this?  like the good old /?find= in WebApp Builder. 


Ref:
https://doc.arcgis.com/en/experience-builder/latest/build-apps/url-parameters.htm#:~:text=Experience...

https://community.esri.com/t5/forums/searchpage/tab/message?advanced=false&allow_punctuation=false&f... 


ShengdiZhang
Esri Regular Contributor

Hi @FredericPoliart_EsriAU ,

If you have already configured the required data source and search fields in the search widget, you can simply use the URL parameter of the search widget without specifying the data source id.

You need to turn on the search widget URL status in the general settings. In your specific case, the URL will be as follows:

https://experience.arcgis.com/experience/<AppId>#widget_30=search_status:%7B"searchText"%3A"16600080"%7D

 

Besides, the JSON you provided for the search widget doesn't mean it uses multiple data sources, only the dataSourceId is used for searching. If you do configure multiple search sources for the search widget, but only want to filter one layer on load, you can add the sourceID to the URL parameter:

https://experience.arcgis.com/experience/<AppId>#<searchWidgetID>=search_status:%7B"searchText"%3A"<text>"%2C"status"%3A%7B"configId"%3A"<SourceID>"%7D%7D

 

Please refer details at: https://doc.arcgis.com/en/experience-builder/latest/build-apps/url-parameters.htm#ESRI_SECTION2_4481... 

 

If you want to filter the data source on load without using the search widget, you can use the data filter parameter, below is an example URL:

http://experience.arcgis.com/experience/<AppID>/?data_filter=191076bf00d-layer-131:Property_Number%3D16600080

 

Regards,

Shengdi

WorcesterGTSS
Frequent Contributor

@ShengdiZhang I'm trying to do pretty much the same thing - using url parameters that will zoom to a particular parcel boundary using the layer/attribute field configured in the EB Search widget but I haven't been successful. Below is what I've put together (the query is for a parcel ID "02-024-00001")- not sure what I'm doing wrong here. Any advice?

https://experience.arcgis.com/experience/a2380710835a4b8bb9fd9021adea8bd9# widget_3=search_status:%7...

I tried another approach which I explain here and also got stuck so I'm running out of ideas. Thanks for any help you can provide.

Samara

0 Kudos
ShengdiZhang
Esri Regular Contributor

Hi @WorcesterGTSS ,

The cause of this problem is that the search widget is placed inside a controller. The search widget does not load when the page loads.

We can improve this behavior to ensure that the widget is loaded by default when the widget id is in the URL parameter. However, there may be conflicts with other functionality, so we need to discuss this further.

A simple workaround is to select the search widget in the controller - Open widgets on loading:

ShengdiZhang_0-1744006265144.png

Using the data source selection in the URL parameter will make the map zoom work. However, it will not display the Parcel ID information in the URL. Like this URL: https://experience.arcgis.com/experience/a2380710835a4b8bb9fd9021adea8bd9#data_s=id%3AdataSource_1-1... 

Please let me know if you have any other questions.

Thanks

Shengdi

WorcesterGTSS
Frequent Contributor

Ah, got it - thanks so much for the reply!

I don't actually need to have the Search widget in a controller so I removed it. Now it correctly works using this: https://experience.arcgis.com/experience/<appID>#widget_3=search_status:%7B%22searchText%22%3A%22<ParcelID>%22%7D

 

0 Kudos