HOW TO
In ArcGIS Online, fields in a layer can be populated with attribute values from another feature layer using an Arcade expression. This method is useful in enhancing data integrity and enabling synchronized analysis across layers.
In this article, two feature layers named Cities and ClimateData are used. The Cities feature layer contains two fields named CityAddress and ClimateLocationID. The ClimateData feature layer also contains two fields named ClimateAddress and LocationID. When the CityAddress field values match those of the ClimateAddress, the LocationID values are automatically populated in the ClimateLocationID field.
The images below display the attribute table for both the Cities and ClimateData feature layers.
var <variable1> = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), '<Item_ID>', <layer_index), ['*'], false);
var <variable2> = $feature['<field_name1>']; for (var<variable3> in <variable1> ) { var <variable4> = climateFeature['<field_name2>']; if <variable2> == <variable4>) { return <varibale3>['<field_name3>']; } } null
Below is the full working code of the Arcade expression.
var climateDataLayer = FeatureSetByPortalItem(Portal('https://www.arcgis.com'), 'fd3161f30d6f47aba8b58f6fcb5ed488', 0, ['*'], false); var cityAddress = $feature['CityAddress']; for (var climateFeature in climateDataLayer) { var climateAddress = climateFeature['ClimateAddress']; if (cityAddress == climateAddress) { return climateFeature['LocationID']; } } null
The attribute table below displays the ClimateLocationID field of the Cities feature layer populated with values from the LocationID field of the ClimateData feature layer when the CityAddress field values match the ClimateAddress.
Get help from ArcGIS experts
Download the Esri Support App