Select to view content in your preferred language

Does anyone know how I can modify this arcade expression to use featuresetbyname rather than featuresetbyrelationshipname

155
2
Jump to solution
3 weeks ago
chill_gis_dude
Regular Contributor

I have an expression that is supposed to be used between a parent feature class and child table. The expression checks if an entered value in the child table matches a value in the parent table and returns good if so or bad if not. I've learned that featuresetbyrelationship name is bugged if there is a "." in the name of the relationship, which is unavoidable for us as we use a referenced geodatabase that has a "." in it. Does anyone know how I can modify the following script to use FeatureSetbyName and maybe the Filter function so I can avoid the relationship class? My code is below. 

 

// load the related rows, using the name of the relationship class
var related_rows = FeaturesetByRelationshipName($feature, "GIS.SDE.tbl_Valve_FieldPressure")

// get the latest survey
var latest_survey = First(OrderBy(related_rows, "created_date DESC"))

// return a default value if no survey was found
if(latest_survey == null) {
    return "Not surveyed yet"
}

// return good or bad depending on PSI
if(latest_survey.InputPostValvePressure == latest_survey.TargetPSI) {
    return "Good"
}
return "Adjust Pressure - See PDF for Instructions"

 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You can use this code to get the related features using just FeatureSetbyName

var value = $feature.theCommonField;
var fs = FeatureSetByName($map, "GIS.SDE.tbl_Valve_FieldPressure");
var latest_survey = First(OrderBy(Filter(fs, "fieldName = @value"), "created_date DESC"));

 

 

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

You can use this code to get the related features using just FeatureSetbyName

var value = $feature.theCommonField;
var fs = FeatureSetByName($map, "GIS.SDE.tbl_Valve_FieldPressure");
var latest_survey = First(OrderBy(Filter(fs, "fieldName = @value"), "created_date DESC"));

 

 

chill_gis_dude
Regular Contributor

Thank you very much, that did the trick.

I also found a way to it without the filter function because it can fail offline sometimes. For anyone reading, here is the final script that works for me.

// Load the related rows using the FeatureSetByName function
var related_rows = FeatureSetByName($map, "Valve Field Pressure")

// Get the latest survey (sorted by created_date DESC)
var latest_survey = First(OrderBy(related_rows, "created_date DESC"))

// Check if PSI fields are valid
if(latest_survey.InputPostValvePressure == null || $feature.TargetPSI == null) {
    return "Not Surveyed Yet"
}

// Return good or bad depending on PSI
if(latest_survey.InputPostValvePressure == $feature.TargetPSI) {
    return "Good PSI"
}
return "Adjust Pressure - See PDF for Instructions"

 

0 Kudos