Select to view content in your preferred language

Attribute rule returned value but no field was specified - help

195
1
Jump to solution
03-14-2025 11:35 AM
KallieH
New Contributor

Hello, this is my first post so apologies for possible incorrect formatting or post location.

Very new to arcade and coding in general. I am trying to implement an attribute rule into my inspection table that triggers when an inspection is updated or created. Once this attribute rule is triggered it should populate a field in my permits layer stating the job has been completed. But  only if there is a final inspection type detected within the same permit ID (link field/ permit number). 

Attribute rule triggers are insert & update.  Exclude from application evaluation is checked. My errors and code are below. Thank you!

KallieH_1-1741977058714.png

KallieH_0-1741977027830.png

// Get the harvest permit records
var relatedPermits = FeatureSetByName($datastore, "HarvestPermits_ExportFeatures", ["JOB_COMPLETED", "LINK_FIELD", "GLOBALID"], false);

// Get permit number from the record in the table
var permitNumber = $feature.PERMITNUMBER;

// Ensure permit IDs match
var relatedPermit = First(Filter(relatedPermits, "LINK_FIELD = @permitNumber"));

// Check if the current inspection is "final" and a related permit exists
if (Lower($feature.FIELD_INSPECTIONS_TYPE) == 'f' && relatedPermit != null) {
    // Get the globalID of the related permit
    var permitGlobalID = relatedPermit.GLOBALID;

    // Update the harvest permits
    return {
        "edit": [{
            "className": "HarvestPermits_ExportFeatures",
            "updates": {
               "globalID": permitGlobalID,
               "attributes": {
                "JOB_COMPLETED": "Yes"
               }
            }

        }]
    };
} else {
    Console("Conditions not met for update. Inspection Type: " + $feature.FIELD_INSPECTIONS_TYPE);
}

// If no update was made, return null
return null;

 

0 Kudos
1 Solution

Accepted Solutions
MikeMillerGIS
Esri Frequent Contributor
Change return null to just return

Returning null means you are trying to set the assigned field to null.

View solution in original post

0 Kudos
1 Reply
MikeMillerGIS
Esri Frequent Contributor
Change return null to just return

Returning null means you are trying to set the assigned field to null.
0 Kudos