Dictionary type Expected

1650
3
Jump to solution
04-09-2021 02:48 PM
JimWilliams
New Contributor III

Hello,

I was wondering why this would give me a "Dictionary type expected" error

 

 

var grid = featuresetbyname($datastore, 'Grid', ['GridNo'], false);
Console("cnt gird: " + Count(grid));
var grid_intersects = intersects($feature,grid);

var cnt = count(grid_intersects);
Console("cnt gird_name: " + Count(grid_intersects));
console("prefix: " + First(grid_intersects.GridNo))

if (cnt > 0) {
    
    var prefix = First(grid_intersects.GridNo)

    return Concatenate(prefix, NextSequenceValue("SVWD_FacilityID"))
}
else {
    return 'error'
}

 

 

 

and this expression works and returns the values I expected.

 

 

var grid = featuresetbyname($datastore, 'Grid', ['GridNo'], false);
Console("cnt gird: " + Count(grid));
var grid_intersects = intersects($feature,grid);

for(var s in grid_intersects){
return Concatenate(s.GridNo,NextSequenceValue("SVWD_FacilityID"))
}

 

I understand that a for loop will loop over a dictionary (or I assume it will), but in my first statement I am only getting 1 result, why cant I just use a if statement? I noticed a few other posts like this one but no one explains why this error even occurs.

 

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

It's likely the way you're using Concatenate. Rather than concatenating all the arguments (as in Excel or similar), the first argument should be all the items to be concatenated. The second should be the string to separate the items with.

Concatenate([prefix, NextSequenceValue("SVWD_FacilityID")], ' ')

 

Of course, that isn't a dictionary. That seems odd.

Also, it looks like there's another error here:

First(grid_intersects.GridNo)

grid_intersects is a FeatureSet, and has no GridNo property. To access the property, you need to shift the parenthesis.

First(grid_intersects).GridNo

There, we're accessing the GridNo property of the Feature returned by First.

Perhaps the combination of things is causing the dictionary error to pop up, though I can't be sure.

- Josh Carlson
Kendall County GIS

View solution in original post

3 Replies
jcarlson
MVP Esteemed Contributor

It's likely the way you're using Concatenate. Rather than concatenating all the arguments (as in Excel or similar), the first argument should be all the items to be concatenated. The second should be the string to separate the items with.

Concatenate([prefix, NextSequenceValue("SVWD_FacilityID")], ' ')

 

Of course, that isn't a dictionary. That seems odd.

Also, it looks like there's another error here:

First(grid_intersects.GridNo)

grid_intersects is a FeatureSet, and has no GridNo property. To access the property, you need to shift the parenthesis.

First(grid_intersects).GridNo

There, we're accessing the GridNo property of the Feature returned by First.

Perhaps the combination of things is causing the dictionary error to pop up, though I can't be sure.

- Josh Carlson
Kendall County GIS
JimWilliams
New Contributor III

@jcarlsonBataboom batabing that was the issue,

Your answer was spot on. Do you think what is happening is feature sets are actually a dictionary. So the

First(grid_intersects.GridNo)

issue might have been throwing that dictionary error?

jcarlson
MVP Esteemed Contributor

Ah! That's probably it.

- Josh Carlson
Kendall County GIS
0 Kudos