Arcade Error: Dictionary Type Expected

4449
4
Jump to solution
04-29-2020 02:53 PM
JoshSaad1
Occasional Contributor II

I wrote an Arcade expression to calculate the zip code of an address point from its intersecting zip code polygon, and it works just fine: 

var fsZip = FeatureSetByName($datastore, "ZipCodes", ["Zip_Code"])
var fsZipIntersect = Intersects(fsZip, $feature)
var zip = First(fsZipIntersect)

return zip.Zip_Code

I use a similar expression to calculate the municipality from the zip codes feature class with no problems:

var fsZip = FeatureSetByName($datastore, "ZipCodes", ["PO_NAME"])
var fsZipIntersect = Intersects(fsZip, $feature)
var city = First(fsZipIntersect)

return city.PO_NAME

But when I try to do essentially the same process to calculate the intersecting neighborhood or building footprint I get an error, "Dictionary Type Expected".

var fsBuilding = FeatureSetByName($datastore, "BuildingFootprint", ["bldngid"]
var fsBuildingIntersect = Intersects(fsBuilding, $feature)
var Building = First(fsBuildingIntersect)

return Building.bldngid

var fsNeighborhood = FeatureSetByName($datastore, "Neighborhood", ["nbrhdid"])
var fsNeighborhoodIntersect = Intersects(fsNeighborhood, $feature)
var Neighborhood = First(fsNeighborhoodIntersect)

return Neighborhood.nbrhdid

All of my feature classes are in the same file geodatabase that I'm using for testing, so they're all in the same data store.  Does anyone know why this might be happening?

Tags (1)
1 Solution

Accepted Solutions
XanderBakker
Esri Esteemed Contributor

Hi Josh Saad ,

I don't think it is what is causing the error, but the line:

var fsBuilding = FeatureSetByName($datastore, "BuildingFootprint", ["bldngid"]

... is missing a bracket at the end of the line.

I also notice that you don't check if the Intersects is returning any results. In theory it could result a featureset with 0 features and when you apply First on that, this would cause an error (although I think a different one).

I assume you are using the exact names of how these items are named in your FGBD ($datastore), right?

Have you tried with writing messages to the Console on which line this error is occurring and to check that the items used are valid and the expression has access to them?

View solution in original post

4 Replies
XanderBakker
Esri Esteemed Contributor

Hi Josh Saad ,

I don't think it is what is causing the error, but the line:

var fsBuilding = FeatureSetByName($datastore, "BuildingFootprint", ["bldngid"]

... is missing a bracket at the end of the line.

I also notice that you don't check if the Intersects is returning any results. In theory it could result a featureset with 0 features and when you apply First on that, this would cause an error (although I think a different one).

I assume you are using the exact names of how these items are named in your FGBD ($datastore), right?

Have you tried with writing messages to the Console on which line this error is occurring and to check that the items used are valid and the expression has access to them?

JoshSaad1
Occasional Contributor II

Thanks.  I looked into it and resolved the issue by adding the following lines to my expressions (with different variables in each respectively):

if (Building == null) return null

Tiffany_Chau
New Contributor II

Thanks Josh. I had also run into a similar situation (when using the FeatureSetbyName function, Intersect function, and First function, and received the Dictionary Type Expected error message) and a similar solution worked for me. I did:

if (x == null){
return null
}

0 Kudos
CollinHorace
New Contributor II

Hey Xander,

I am also having an issue in ArcGIS Pro with the dictionary type when saving this attribute rule expression that deletes the corresponding Tag ID in the master tag table:

var aTable = $feature["AGLDESCRIPTION"];
var bTable = FeatureSetByName($datastore,"Tags");
var relate = "name = '" + $feature.AGLDESCRIPTION + "'";
var match = Filter(bTable, relate);
var cnt = Count(match);
if (count(match) == 0) return $feature.AGLDESCRIPTION;
var matchfeature = first(match)
return {
//we want to just return the value of field `AGLDESCRIPTION` no change require
"result": $feature.AGLDESCRIPTION,
//this keyword indicates an edit that need to happen, its an array since we can make many edits
"edit": [
{
//the other class we want to edit
"className" : "Tags",
//the type of edit, in this case we want to delete so we say `deletes`, its an array since we can make many deletes
"deletes" : [
{
//what feature we need to delete?
"globalID" : bTable.GlobalID
}
]
}
]
}

 

0 Kudos