Hi all! I am somewhat new to using Arcade and need some help to populate a field based on the most recent related record.
The field I would like to populate is CRNT_DAMAGE from the newest related record "Individual Palm Damage Survey" based on the field "SurveyDate". The condition I would like met is if "SpearDamage" and "BoreHoles" == No as well as "InnerFrondsDamaged" and "OuterFrondsDamaged" == 0, then the return value would be "No" for CRNT_Damage. All else would return "Yes".
Please comment bellow if you have suggestions or can refer me to a similar expression.
Thank you all!
// load the related rows, using one of two ways:
// either load the featureset and filter it (replace the key field names)
var related_fs = FeaturesetByPortalItem(...)
var key_value = $feature.PrimaryKey
var related_rows = Filter(related_fs, "ForeignKey = @key_value")
// or load only the related rows, using the name of the relationship class
var related_rows = FeaturesetByRelationshipName($feature, "RelationshipName")
// get the latest survey
var latest_survey = First(OrderBy(related_rows, "SurveyDate DESC"))
// return a default value if no survey was found
if(latest_survey == null) {
return "not surveyed yet"
}
// if all damage types are non-existent, the palm is undamaged
if(latest_survey.SpearDamage == "No" && latest_survey.BoreHoles == "No" && latest_survey.InnerFrondsDamaged == 0 && latest_survey.OuterFrondsDamaged == 0) {
return "No"
}
// else it is damaged
return "Yes"
Johannes- this is awesome, I'm looking forward to implementing this expression!
Thank you thank you!
Judging from the fields, you are writing this expression in the palm survey table. But it should be written for the palm layer.