Select to view content in your preferred language

Arcade expression not working automatically on web app / field app

703
6
11-05-2024 12:03 AM
yockee
by
Frequent Contributor

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:

yockee_0-1730793771936.png

 

0 Kudos
6 Replies
ChristopherCounsell
MVP Regular Contributor

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.

0 Kudos
yockee
by
Frequent Contributor
I update the table on the web map app. I do not edit the spatial, only edit
attribute.
Even using Field Map, the arcade function is not invoked.
0 Kudos
yockee
by
Frequent Contributor

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'}
            }]
        }]
    }

 from: https://community.esri.com/t5/arcgis-pro-questions/using-arcade-to-edit-an-attribute-in-another/m-p/...

0 Kudos
ChristopherCounsell
MVP Regular Contributor

Do you have both editing and calculation enabled on the feature in the form? If so, the expression won't run:

https://doc.arcgis.com/en/field-maps/latest/prepare-maps/configure-the-form.htm#ESRI_SECTION2_5F65DF...

 

0 Kudos
yockee
by
Frequent Contributor
How to check if editing and calculation are enabled ?
My service is a feature service with update geometry and attribute
enabled...
0 Kudos
ChristopherCounsell
MVP Regular Contributor

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?

0 Kudos