Hi Doug,
Thanks for helping.
So I am setting this code on the respective field on the "Inspections" form. See the screenshot below:
Now if I change the code as per your advice above to this:
var allHydrants = FeaturesetByName($datastore, 'Hydrants', ['FACILITYID', 'ObjectID'], false);
var facility_id = $feature.FACILITYKEY; //this should be the ID of the currently selected hydrant
var thisHydrant = First(Filter(allHydrants, 'FACILITYID = @facility_id'));
//If the CHAINS field gets toggled to "YES" in the collection form, then we need to update the INSP_STATUS attribute on the feature to YES
if (($feature.CHAINS != "NO"))
{
//abort if no hydrant was found
if (thisHydrant == null){return};
return "WR";
};
Now when I do this, I still don't get what I want. What is happening is that a "WR" is now getting substituted for the "switch" control. But what I want, is for the switch control to update the feature based on wether or not the switch is in the No or Yes position.....if that makes any sense.
Ultimately what I want to do is replicate what we currently have working in our ArcPad inspection applications. So the user clicks on a hydrant, an inspection form opens up and based on what is selected in the inspection form, the INSP_STATUS field on the hydrant gets updated.....either to "WR" (work required) or to "YES" (a completed inspection with no issues).
All of these Inspections are saved in a related table to the hydrant....the INSPECTIONS table. I guess with Field Maps we could have the technician doing the inspection manually toggle the INSP_STATUS on the feature after each inspection to either WR or YES, but I'm trying to avoid them having to do that, as ultimately that will get screwed up in the field and hydrants that should be at WR will get missed.
Currently in ArcPad, this all automated through a script when they hit the "Save" button at the end of the inspection. So ideally with Field Maps, once they hit the "Submit" button after they fill out the entire inspection form, is where this business logic would happen to determine how to update the INSP_STATUS field on the hydrant. For now, I am just trying to get it to work with the one field CHAINS, but in reality I would need to look at about 10 different fields before I determine whether to set it to WR or to YES.
Hopefully this makes sense. This is something I've been trying to sort out with esri for years, and there is still no solution. I've met with people at the Dev Summit, sat in countless web demos of Fields Maps and still there is no solution to this.
Hopefully you have some ideas that can point me in the right direction.
Recently I've looked at the Maps SDK, but I'd like to stick to something more simpler than redeveloping all 9 of our field inspections apps from scratch in the Maps SDK. Not sure we have the manpower for that.