Select to view content in your preferred language

Error in Filter when creating Arcade Data Expression

1251
3
Jump to solution
03-30-2023 07:09 AM
Labels (1)
ZachLansford_HD
New Contributor II

Hi everyone,

 

I am trying to create a Data Expression within my dashboard to access some related records. I've set up a filter to access the data but am getting an error when trying to access the data from the Filter. 

 

"Test execution error: Unknown Error. Verify test data."

 

I've added a few console outputs to test my results. I am able to get the output for the first console statement but then run into the error.

 

I've added the relevant portion of the script below.

 

var portalServ = Portal("https://www.arcgis.com/");
var pointFS = FeatureSetByPortalItem(
  portalServ,
  "featID",
  0,
  ["*"],
  False
);

var tablefs = FeatureSetByPortalItem(
  portalServ,
  "featID",
  1,
  ["*"],
  False
);


var features = [];
var feat;
var calls_sub_found_var;

for (var t in tablefs){
  var TableID = t["op_record_id"]
  console(TableID);
  for (var p in Filter(pointFS,"op_record_id = "+Text(TableID))){
    console(p["op_record_id"]);
  }
}

 

Additionally, if I use the console to output the Filter object itself, I am able to return that. It is only when I try and start accessing the objects from the filter when I run into the error.

Would the amount of data be a factor in the filter failing? I'm working with ~120k point features and ~20k related records in total.

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

Is op_record_id field a string field or numeric? If it's a string, you'll need quotes. Or you can avoid that by using @variable

var TableID = Text(t["op_record_id"]);
for (var p in Filter(pointFS,"op_record_id = @TableID")){

View solution in original post

3 Replies
KenBuja
MVP Esteemed Contributor

Is op_record_id field a string field or numeric? If it's a string, you'll need quotes. Or you can avoid that by using @variable

var TableID = Text(t["op_record_id"]);
for (var p in Filter(pointFS,"op_record_id = @TableID")){
ZachLansford_HD
New Contributor II

It is a string field - this solved my issue. Thanks a bunch!

0 Kudos
jcarlson
MVP Esteemed Contributor

When you return the filtered object, what does it look like?

When I write a filter statement, I prefer to use template literals:

Filter(pointFS,`op_record_id = ${TableID}`)

In general, when you're working with a filtered FeatureSet, you ought to include an if statement that checks to see that there are any features. Expressions can sometimes break when they attempt to work with a FeatureSet that has nothing in it.

var filtered = Filter(...)

if (Count(filtered) > 0) {
  for (var p in filtered) {
    ...
  }
}

Is there a real relationship class between the layers? Why not use FeatureSetByRelationShipName?

- Josh Carlson
Kendall County GIS
0 Kudos