Filling in data from Portal Item

455
4
07-24-2023 06:50 AM
LorindaGilbert
Occasional Contributor II

Hi,

Have searched the forum but didn't find anything.

I'm writing attribute rules in ArcPro for the LGS Addressing.  I'm wanting to fill in columns from other data that has been published to our Enterprise Portal.  Parcels, Zipcodes, Municipalites specifically, I've got the var for the portal item and set up the AR, it all validates.  However, when placing a new feature, it fills in the columns with the text for the name of the column - PID, Zip, City - not the value.  Any help would be appreciated.

One of the ARs:

// This rule will calculate the Zipcode the site address falls within

// Define the Site Addresses fields
var portal = Portal('//server.domain/portal/')
var zip_field = "ZipCode"; // column name in Situs Address layer

if (IsEmpty(zip_field)) {

var fs = FeatureSetByPortalItem(portal, 'Zip Codes', 0, ['ZIP_CODE'], true);
var zip_field = First(Intersects($feature, fs));

}
else {
zip_field = zip_field
}
return zip_field;

 

Thanks,

Lorinda

4 Replies
jcarlson
MVP Esteemed Contributor

This line:

var zip_field = First(Intersects($feature, fs));

You're taking the initial string, 'ZipCode', and replacing it with the output of that function, which is a Feature.

If you really want to get the value from that zip code, you need to use dot or bracket notation to return a specific attribute from it.

var xs_feat = First(Intersercts($feature, fs))

xs_feat['ZipCode']

xs_feat.ZipCode

Also, at the end, you're returning the value of the variable zip_field, but your else block isn't doing anything to that variable. So if the field is not empty, your expression will replace whatever is in that field with the literal string 'ZipCode'.

If you want to leave the field alone and retain its existing value, use $feature['the_field_you_are_updating'].

- Josh Carlson
Kendall County GIS
0 Kudos
LorindaGilbert
Occasional Contributor II

Thanks Josh,

I figured that is was something silly that I was overlooking.  I'm rather new to ARs and this is only my second go around - first wasn't filling in data from other sources, only calculating values.  The other project was using Arcade for filling in info boxes, it seems to be much different than using Arcade for AR.  And I'm finding very few examples online.

So I changed it to this and now getting nothing.  So I'm still missing something on it.  Did try both .ZipCode and [ZipCode].

// This rule will calculate the Zipcode the site address falls within

// Define the Site Addresses fields
var portal = Portal('//server.domain/portal/')
var zip_field = "ZipCode";

if (IsEmpty(zip_field)) {

var fs = FeatureSetByPortalItem(portal, 'Zip Codes', 0, ['ZIP_CODE'], true);
var zip_feat = First(Intersects($feature, fs));
zip_field = zip_feat['ZipCode']
}
else {
zip_field = zip_field
}
return zip_field;

0 Kudos
jcarlson
MVP Esteemed Contributor

Sorry, I should have caught this the first time, too. You're checking IsEmpty(zip_field) right after assigning a value to the variable, so it's never going to evaluate as True.

If you want to check if that field is empty, you need to access the feature's attributes.

if(IsEmpty($feature['ZipCode']) {
...
}

 And also, the intersected feature will follow the schema from the other layer, so it should actually be

zip_feat['ZIP_CODE']

See if that makes a difference?

- Josh Carlson
Kendall County GIS
0 Kudos
LorindaGilbert
Occasional Contributor II

Josh,

Sorry for delay, was out of office for a bit.

Made the changes but then get this message

LorindaGilbert_0-1690390206143.png

Have tried several different ways of doing the zip_feat.ZIP_CODE; also tried using the alias name for the column, tried entering the GUID for the layer name (unless I had the wrong one).

Now going to look into FeatureSetbyID or byName.

 

0 Kudos