Select to view content in your preferred language

use arcade to auto populate from layer field

725
4
10-03-2023 06:54 PM
MiltonVrolijk
Emerging Contributor

ArcGIS Pro 3.1

I want to auto populate from feature layer field "TDA_ID" to related table "assesment" with the same field "TDA_ID" and "repair_report" and also with the same field "TDA_ID".

I use this expression but did not work.

var originFeatureSet = FeatureSetByName($datastore, "TrafficDamageAssessment", ["TDA_ID"], true);

 

// Check if the current feature's TDA_ID is valid

if (IsEmpty($feature.TDA_ID)) {

    return null;

}

 

var whereClause = "TDA_ID = '" + $feature.TDA_ID + "'"; // Assuming TDA_ID is a string. If it's numeric, remove the single quotes.

var relatedFeature = First(Filter(originFeatureSet, whereClause));

 

if (!IsEmpty(relatedFeature)) {

    return relatedFeature.TDA_ID;

}

 

return null;

0 Kudos
4 Replies
KenBuja
MVP Esteemed Contributor

If you have a relate set up for the two tables, you can use the FeatureSetByRelationshipName function

 

var relatedFS = FeatureSetByRelationshipName($feature, 'relate name');
return First(relatedFS).TDA_ID

 

If they don't have a relationship, a note about constructing the sqlExpression for the Filter. You can make use of the Arcade variable substitution so you don't have to worry whether a value needs quotes or not

 

var tdaid = $feature.TDA_ID;
var relatedFeature = First(Filter(originFeatureSet, "TDA_ID = @tdaid"));

 

 

 

 

MiltonVrolijk
Emerging Contributor

Thanks

0 Kudos
ZachBodenner
MVP Regular Contributor

Also, take a look at a thread. JonnesLidner's response to my question about the exact same thing was super detailed and helpful.

0 Kudos
MiltonVrolijk
Emerging Contributor

Thanks for the heads up

0 Kudos