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!
// 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;
Solved! Go to Solution.