Empty featureset in arcade in dashboard

188
4
2 weeks ago
mody_buchbinder
New Contributor III

I am trying to create a pie chart in dashboard using arcade.

I am query a layer by a list of values and create some values for the pie.

The basic lines is

 var sql = "GlobalID = '" + globalId + "'";
var featureLocation = Filter(fs_location, sql);

where the golbalID change in a loop.

It all works fine when the feature set contain values. The problem is when it return nothing.

I tried "isEmpty(featureLocation)" but it return an error.

I tried some simple loop:

var c = 0
for(var s in featureLocation)
{
c = c + 1
}

it return an error too.

Unlike many of the examples I do not have $feature here.

Any good way to understand nothing is coming back and does not get an error?

 

Thanks

 

0 Kudos
4 Replies
JohannesLindner
Occasional Contributor II

If you expand the tollbar in the comment box, you can insert code samples:

JohannesLindner_0-1622633201561.png

 

Try this:

if(Count(featureLocation) == 0) {
  // noting found, return null
  return null
}

Have a great day!
Johannes
KenBuja
MVP Honored Contributor

This appears to be a problem when filtering by GlobalID. If you put in a filter clause on a field that returns no values (like "var filter = Filter(fs, 'objectid = 0')"), the filter count is 0.

 

0 Kudos
mody_buchbinder
New Contributor III

Hi

I found out that when the globalID is empty you get an error.

Still the expression GlobalID = '' is valid but any reference to the featureSet it returns (including Count) return an error.

0 Kudos
JohannesLindner
Occasional Contributor II

Have you tried checking for null?

if(featureLocation == null || Count(featureLocation) == 0) {
  // noting found, return null
  return null
}

Have a great day!
Johannes
0 Kudos