All,
I have a map with a point feature (Gas Leak) and a related table (Leak Monitor)
I am working on using calculated expressions to "Classify" the leak on initial discovery, and update that same classification based on continous leak monitors. So basically, when a leak is discovered, the class will be decided for the user based on other attributes they fill out. That code works perfectly fine. Before it evaluates this class however, it checks to see if any related "Leak Monitors" exist, and if so, what the updated class from those entries is. I've done multiple expressions to pull information from related records and am pretty comfortable with it. Where things seem to be hanging up is when these records do not exist. I have tried using !IsEmpty(RelatedMonitors), !is NaN(RelatedMonitors) and the count method shown below. No matter what I try, if there are no related monitors, it only tells me that it failed to calculate in field maps on IOS. It seems to work as intended in the expression builder in AGOL when I test. But will not work on iPhone. It's almost like it doesn't know if related records exist yet? Hoping someone can help me figure out what is going on here. Thanks
// Pull the NewLeakClass fields from all related records.
var RelatedMonitors = featuresetbyrelationshipname($feature, 'LeakMonitor',['NewLeakClass'],False)
//take the first record from all related records
var NewestMonitor = First(RelatedMonitors)
//Count number of related records
var NumRelMons = Count(RelatedMonitors)
//if the count is not 0, then it tells me there are monitors
if (NumRelMons != 0){
return "YesMon"
//if the count is 0 then, it tells me there are no monitors
}else {
return "NoMon"
}