Hi there,
I am trying to use the calculate expression using the configure form on ArcGIS online map viewer. I want to overlay a polygon on top of a layer and based on that intersection, the "CW_Status" field of the layer will switch to "Active". I also want the "CW_Status" to revert back to "Inactive" once the intersecting polygon has been removed. Here is the code I created that does not work.
// Overlay polygon
var overlay = FeatureSetByName($map, "DWA_Area")
// intersecting boolean
var intersect = Intersects($feature, overlay)
if(intersect == true){
return ($feature.CW_Status = "Active");
} else {
return $feature.CW_Status;
}
Thanks!
Hey @ShaiBravo
When you say that the code does not work, does it not return anything, or only one of the options?
Cody
Technically my code gives me a return, but the field "CW_Status" remains "Inactive" when I place the intersecting polygon over top. The expected return should be "Active"
Hey @ShaiBravo
I was curious if it could be in the formatting of your if statement, is the default "Inactive"? If so, maybe attempt to do this:
if (intersect) {
return "Active";
} else {
return "Inactive";
}
Only because maybe it has to do with true maybe being True, or another form different, this should be a definitive as the already is a boolean when assigned I believe!
Hope this helps!
Cody
I get a "Test execution error: Execution error - Conditions must use booleans. Verify test data." error when I use the new method. When I use this method, I get an "Inactive" return
if(intersect == true){
return "Active";
} else {
return "Inactive";
}
Hey @ShaiBravo
Very strange, maybe Arcade doesn't adhere to major programming standards, but either way, it may be useful to attempt and return the intersect and overlay value, it could be the case that nothing is being used in the variable and it's just empty from the start. That's only an idea though, but may be worth a shot!
Cody
Just adding to this if anybody is interested.
I chatted with Esri yesterday and they consider my method another version of bulk editing which is not supported on Experience Builder. They then suggested I try to use the calculate field in the data management of the layer. By trying this method, my code does not work because it can only use the features within the layer. So it seems like there is no way to do what I want to accomplish with the tools Esri has available.
I will update if I can come up with a solution.