URL parameters - filter multiple data sources

533
6
02-05-2024 06:18 AM
elpinguino
Occasional Contributor III

Hi ExBers,

I want to apply the data_filter in my URL parameters. I was linked this article to follow. https://doc.arcgis.com/en/experience-builder/latest/build-apps/url-parameters.htm#ESRI_SECTION1_0A01...

I have some experience using ArcGIS Assistant and URL parameters in Dashboard, so understand a little, but not a whole lot.

I have three layers I want filtered, and I want these to filter in the web map and all the other widgets which have triggers and actions on them.

I want them filtered at the time of the user enters the Experience Builder. Previously I was querying the layers in Map Viewer and that meant a long ExB set up time anytime we switched out the web map.

How do I know which data source is 1, 2 and 3? Do I figure that out by looking in Experience Builder's data source properties of the map or should I have a look in ArcGIS Assistant?

This is what I've tried using our Test site and with the appid removed for privacy purposes.

https://experience.arcgis.com/experience/<appid>/?data_filter=ds1:OperationName%3D%27TestD%27,ds2:OperationName%3D%27TestD%27,ds3:OperationName%3D%27TestD%27

This is the query I want to apply to all of them- OperationName=Test or should it be OperationName='Test'?

Hopefully you can point me in the right direction.

0 Kudos
6 Replies
MichaelGaiggEsri
New Contributor III

Here is an easy way to identify the datasource Id of a layer:

https://www.youtube.com/watch?v=gUy_tPPuvjk

MarcCavallaro
New Contributor III

Video is private, any chance you could make it available?

0 Kudos
elpinguino
Occasional Contributor III

@MichaelGaiggEsri Great video- Easy peasy lemon squeasy. haha! You've got another follower.

To add a curve ball to that. I left out some info that in hindsight is essential. The three layers I want to filter in the map/widgets are all sublayers of one feature service (sub layers 45,47 and 48). Watching your video reminded me of that... So they are all dataSource_1 (ds1 for data_filter). I've tried to filter all of them, but only the first one listed seems to apply the filter.

https://experience.arcgis.com/experience/<appid>/?data_filter=ds1-xxxxxxxxxxx-layer-45:OperationName%3D%27Test%27,ds1-xxxxxxxxxxx-layer-47:OperationName%3D%27Test%27,ds1-xxxxxxxxxxx-layer-48:OperationName%3D%27Test%27

So I haven't solved it fully, but wanted to give you a status update since you were so quick to make that video reply. Thanks!

0 Kudos
MichaelGaigg
Esri Contributor

Glad you liked the video 😉 

Looks like your values are strings, try adding single quotes (') around the values. If that doesn't work, maybe you need to use url escape characters (https://www.w3schools.com/tags/ref_urlencode.ASP)

 

' = %27

, = %2C

etc.

0 Kudos
elpinguino
Occasional Contributor III

As a url parameter newbie it took me a while, but I finally solved it, and now this should save me loads of time when I need to add in new operations.

Michael helped me out a lot with his video explanation and think through the process a bit more.

As a note for people new to url parameters that might want to apply data_filters to their workflow these are some things to be aware of:

  • Sometimes once you hit enter it will encode some of your unencoded characters for you like : to %3A, so it's probably best to follow the documentation and make sure everything is encoded from the start =, &, : etc
  • The datasource id will be slightly different if you use a map widget vs a non-spatial widget like a list
  • If you are filtering sublayers from the same feature service it's the same, but slightly different... that's the best way to explain it without including the exact url parameters

It would be worth considering putting points 2 and 3 in the URL Parameter section of the Experience Builder documentation as it would help more URL Parameter beginners to explore its possibilities and applying it to their projects.

Shen_Zhang
Esri Contributor

Hi @elpinguino 

Thank you for the suggestions above on data filter parameters. As some new URL parameters will be introduced in the upcoming Online release, we will update the documentation, of course with some of your ideas!

As you mentioned on URL encoding, the best way to make data filters work is to make sure the filter value is encoded. Do not encode characters used for delimiters. This is an example:

?data_filter=ds1:objectid%3D1,ds2:fieldA%3E2

"," ":" and "=" are used for delimiters, and should not be encoded. Although we also have some logic implemented for tackling these cases, the best way to make the URL work is to encode the values only.

Shen Zhang