I want to populate an attribute based on another attribute value using arcgis arcade on a web map / field map.
Suppose I have 2 attributes: attribute1 and attribute2. Attribute1 will be updated if Attribute2 has certain value. Here is the code on attribute1:
if ($feature.attribute2 != "b")
{
return "yy";
}
else
{
return "xy";
The formula is correct. But why attribute1 is not updated automatically when attribute2 is updated / inserted (I update the atribute by changing the column value of atribute2) ?
Here is the screenshot:
Are you editing via the attribute table or via the form with the arcade calculation?
Updating the table directly typically doesn't invoke the form based calculation.
You need to edit the feature via the form in the web map, field map, or using a widget in an app.
I wonder if this " return "xy"; " actually modifies the content (attribute) of the feature. Because no errors are reported and the apps working fine but the field is still not changing.
Perhaps the correct thing is this:
return { 'edit': [{ 'classname' : 'WAT_Hydrant', 'updates' : [{ 'objectID': hydrant.ObjectID, 'attributes' : {'INSP_STATUS' : 'OOS'} }] }] }
Do you have both editing and calculation enabled on the feature in the form? If so, the expression won't run:
In the form. Where you have configured the arcade expression to calculate it.
Can you show your form in map viewer and were you are applying the edits?