Select to view content in your preferred language

How to write two where clause in URL Parameter?

427
1
Jump to solution
03-05-2024 12:53 AM
GeeteshSingh07
Occasional Contributor II
Hi Everyone, I am looking for a way to write two 'where clauses' in the URL parameter. Using this URL, the feature ID with UID=4 will be selected. https://experience.arcgis.com/experience/fd354455c7154e8d8a554f7c6da465ba/?draft=true#data_s=where:d... I want to set the query "WHERE UID =4,5,6,7", then, is there a way to achieve this? Reference: https://doc.arcgis.com/en/experience-builder/latest/build-apps/url-parameters.htm#GUID-ADD3075D-D8DE... As per the document, there are three selection types: id, geometry, and where. Does id only works for ObjectID field or is there a way we can use different field as ID?
0 Kudos
1 Solution

Accepted Solutions
Shen_Zhang
Esri Contributor

Hi @GeeteshSingh07 

The id type only works for OID or FID. If you want to use select for other fields, you should use where clauses, For example in your case:

"WHERE UID =4,5,6,7", you can use

 

#data_s=where:<dataSource_ID>:UID%20IN%20(4%2C5%2C6%2C7)

 

And if you want to add another clause, you can use AND to concatenate them, just like any standard where clause does:

#data_s=where:<dataSource_ID>:UID IN (4,5,6,7) AND City = ’LA’ 

And please encode the data_s parameter value to make sure it work, like the following:

#data_s=where:<dataSource_ID>:UID%20IN%20(4%2C5%2C6%2C7)%20AND%20City%20%3D%20’LA’%20

 

Furthermore, if you're not sure how to write a SQL clause, you can use Select widget to set up a SQL expression. Here are the steps for your reference:

1. Add a table widget and create a sheet with the data you like (so you can see the result from URL parameters)

2. Add a select widget, choose Select by Attributes. Click Add new data and select the same data of that you chose for table

3. Click SQL Expression Builder to set up the clauses.

4. Save the app and go to preview. Click Attribute selection and enable the toggle appeared below.

Screenshot 2024-03-06 at 15.09.50.png

At this time, you should be able to see the data_s with a where clause. You can try different SQL expressions to explore. 

Hope this info can help as you explore URL parameters. Please come to us anytime you run into issues. thanks!

Shen Zhang

View solution in original post

0 Kudos
1 Reply
Shen_Zhang
Esri Contributor

Hi @GeeteshSingh07 

The id type only works for OID or FID. If you want to use select for other fields, you should use where clauses, For example in your case:

"WHERE UID =4,5,6,7", you can use

 

#data_s=where:<dataSource_ID>:UID%20IN%20(4%2C5%2C6%2C7)

 

And if you want to add another clause, you can use AND to concatenate them, just like any standard where clause does:

#data_s=where:<dataSource_ID>:UID IN (4,5,6,7) AND City = ’LA’ 

And please encode the data_s parameter value to make sure it work, like the following:

#data_s=where:<dataSource_ID>:UID%20IN%20(4%2C5%2C6%2C7)%20AND%20City%20%3D%20’LA’%20

 

Furthermore, if you're not sure how to write a SQL clause, you can use Select widget to set up a SQL expression. Here are the steps for your reference:

1. Add a table widget and create a sheet with the data you like (so you can see the result from URL parameters)

2. Add a select widget, choose Select by Attributes. Click Add new data and select the same data of that you chose for table

3. Click SQL Expression Builder to set up the clauses.

4. Save the app and go to preview. Click Attribute selection and enable the toggle appeared below.

Screenshot 2024-03-06 at 15.09.50.png

At this time, you should be able to see the data_s with a where clause. You can try different SQL expressions to explore. 

Hope this info can help as you explore URL parameters. Please come to us anytime you run into issues. thanks!

Shen Zhang
0 Kudos